#include <bits/stdc++.h>
using namespace std;
using ll = long  long;
int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(nullptr);
    ll n,q;
    cin>>n>>q;
    vector <ll> in(n);
    vector <ll> in2;
    for (auto &i:in) {
        cin>>i;
    }
    in2 = in;
    sort(in2.begin(),in2.end());
    in2.erase(unique(in2.begin(),in2.end()),in2.end());

    for (int i=0;i<n;i++) {
        in[i]=lower_bound(in2.begin(), in2.end(),in[i])-in2.begin();
    }
    vector <set <ll>> lol(in.size());

    for (int i=in.size()-1;i>=0;i--) {
        lol[in[i]].insert(i);
    }
    vector <bool> used(n+1,false);
    vector <ll> idx(n,-1);
    vector <ll> kek;
    kek.push_back(in[0]);
    idx[0]=1;
    used[0]=true;
    while (kek.size()!=n) {
        bool flag = false;
        for (int i=0;i<n;i++) {
            if (in[i]!=kek.back() and !used[i]) {
                kek.push_back(in[i]);
                idx[i]=kek.size();
                flag = true;\
                used[i]=true;
                break;
            }
        }
        if (!flag) {
            for (int i=0;i<n;i++) {
                if (in[i]==kek.back() and !used[i]) {
                    kek.push_back(in[i]);
                    idx[i]=kek.size();
                    used[i]=true;
                    break;;
                }
            }
        }

    }
    while (q--) {
        ll t,x;
        cin>>t>>x;
        if (t==2) {
            cout<<idx[x-1]<<"\n";
        }else {
            if (n==1) {
                continue;
            }
            swap(in[x-1],in[x]);
            if (in[x]==in[x-1]) {
                continue;
            }
            used.assign(n+1,false);
            idx[0]=1;
            used[0]=true;
            kek.clear();
            kek.push_back(in[0]);

            while (kek.size()!=n) {
                bool flag = false;
                for (int i=0;i<n;i++) {
                    if (in[i]!=kek.back() and !used[i]) {
                        kek.push_back(in[i]);
                        idx[i]=kek.size();
                        flag = true;\
                        used[i]=true;
                        break;
                    }
                }
                if (!flag) {
                    for (int i=0;i<n;i++) {
                        if (in[i]==kek.back() and !used[i]) {
                            kek.push_back(in[i]);
                            idx[i]=kek.size();
                            used[i]=true;
                            break;;
                        }
                    }
                }

            }


        }

    }

}