#include <bits/stdc++.h>
#pragma ("O3")
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define MX LLONG_MAX
#define MN LLONG_MIN
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int N = 1e5 + 2;

int f[N];

void update(int i,int x)
{
    for(i = i + 1; i < N; i += (i & -i))
    {
        f[i] += x;
    }
}

int get(int i)
{
    int res = 0;
    for(i = i + 1; i < N; i -= (i & -i))
    {
        res += f[i];
    }
    return res;
}

const int mod = 998244353;

int binpow(int a,int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1)
        {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        b>>=1;
    }
    return res;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    ifstream("input.txt");
//    ofstream("output.txt");

//    random_device rnd();
//    mt19937 gen(rnd());
//    uniform_int_distribution<> dis(0,n-1);
//    dis(gen);

    int n,q;
    cin>>n>>q;
    vector<int>a(n);
    for(int i= 0 ; i<n; ++i)
    {
        cin>>a[i];
    }

    vector<int>ans1(n);
    vector<vector<int>>pos1(n + 1);
    for(int i = n - 1; i >=0; --i)
    {
        pos1[a[i]].push_back(i);
    }

    ans1[0] = 0;
    pos1[a[0]].pop_back();
    int s;


    for(int i = 1; i<n; ++i)
    {
        int mn = 1e9 + 7;
        for(int j = 0; j<=n; ++j)
        {
            if(!pos1[j].empty() && a[ans1[i-1]] != j)
            {
                if(mn > pos1[j].back())
                {
                    mn = pos1[j].back();
                    s = j;
                }
            }
        }
        if(mn == 1e9+7)
        {
            for(int j = 0; j<=n; ++j)
            {
                if(!pos1[j].empty())
                {
                    for(int k = i; k<n; ++k)
                    {
                        ans1[k] = pos1[j].back();
                        pos1[j].pop_back();
                    }
                }
            }
            break;
        }
        pos1[s].pop_back();
        ans1[i] = mn;
    }
//    for(int i = 0;i<ans1.size();++i){
//        cout<<ans1[i] + 1<<" ";
//    }
//    return 0;

    while(q--)
    {
        int t;
        cin>>t;
        int x;
        cin>>x;
        if(t == 1)
        {
            swap(a[x-1],a[x]);
            vector<int>ans(n);
            vector<vector<int>>pos(n + 1);
            for(int i = n - 1; i >=0; --i)
            {
                pos[a[i]].push_back(i);
            }

            ans[0] = 0;
            pos[a[0]].pop_back();
            s;


            for(int i = 1; i<n; ++i)
            {
                int mn = 1e9 + 7;
                for(int j = 0; j<=n; ++j)
                {
                    if(!pos[j].empty() && a[ans[i-1]] != j)
                    {
                        if(mn > pos[j].back())
                        {
                            mn = pos[j].back();
                            s = j;
                        }
                    }
                }
                if(mn == 1e9+7)
                {
                    for(int j = 0; j<=n; ++j)
                    {
                        if(!pos[j].empty())
                        {
                            for(int k = i; k<n; ++k)
                            {
                                ans[k] = pos[j].back();
                                pos[j].pop_back();
                            }
                        }
                    }
                    break;
                }
                pos[s].pop_back();
                ans[i] = mn;
            }
            ans1 = ans;
        }
        else
        {
            cout<<ans1[x-1] + 1<<endl;
        }
    }
//    for(int i=0;i<n;++i){
//        cout<<ans[i] + 1<<" ";
//    }
}
