#include<bits/stdc++.h>

#define int long

using namespace std;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    while (q--)
    {
        int type;
        cin >> type;
        if(type == 1){
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        }
        else{
            int x;
            cin >> x;
            x--;
            //for(auto x : a) cout << x << " ";
            //cout << " a\n";
            vector<int> res(n);
            vector<int> sz;

            int nid = 0;
            int combo = 1;
            int st = 0;
            int need = -1;
            vector<deque<int>> ord;
            ord.push_back({});
            ord[0].push_back(0);
            for(int i = 1; i < n; i++){
                if(a[i] != a[i - 1]){
                    nid++;
                    ord.push_back({});
                    ord[nid].push_back(i);
                    combo = 1;
                    st = i;
                }
                else{
                    ord[nid].push_back(i);
                }
            }
            deque<int> has;
            for(int i = 0; i <= nid; i++) has.push_back(i);
            int nw = 1;
            //cout << has.size() << " sz\n";
            while (has.size() >= 2)
            {
                int fr = has[0], sc = has[1];
                //cout << fr << " " << sc << "\n";
                res[ord[fr][0]] = nw;
                nw++;
                res[ord[sc][0]] = nw;
                nw++;
                ord[fr].pop_front();
                ord[sc].pop_front();
                if(ord[sc].empty()){
                    has.pop_front();
                    has.pop_front();
                    has.push_front(fr);
                }
                if(ord[fr].empty()) has.pop_front();
                //for(auto x : has) cout << x << " ";
                //cout << " s\n";
                if(has.size() > 1 && has[0] == sc) swap(has[0], has[1]);
                
            }
            //cout << has.size() << " itog\n";
            if(has.size() == 1){
                int lst = has[0];
                //cout << lst << " " << ord[lst].size() << " lst\n";
                while (!ord[lst].empty())
                {
                    res[ord[lst][0]] = nw;
                    //cout << ord[lst][0] << " bad\n";
                    nw++;
                    ord[lst].pop_front();
                }
            }
            cout << res[x] << "\n";
        }
    }
    
}
/*
10 5
1 2 2 2 3 4 5 6 7 8
1 1
1 2
1 3
1 4
2 3
*/