#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--;
            int res = -1;
            vector<int> was(n);
            int ban = -1;
            int nw = 1;
            bool OK = 1;
            while (OK)
            {
                OK = 0;
                for(int i = 0; i < n; i++){
                    if(was[i] || a[i] == ban) continue;
                    OK = 1;
                    if(i == x) res = nw;
                    ban = a[i];
                    was[i] = 1;
                    nw++;
                    break;
                }
            }
            for(int i = 0; i < n; i++){
                if(was[i]) continue;
                if(i == x) res = nw;
                nw++;
            }
            cout << res << "\n";
        }
    }
    
}