#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18, MOD = 998244353;
mt19937 rnd(time(0));

void solve();

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> pos(n);
    vector<int> tt(n);
    vector<int> used(n);
    int pr = -1, f = 0;
    for (int i = 0; i < n; i++){
        if (f){
            for (int j = 0; j < n; j++){
                if (used[j]){continue;}
                pos[j] = i;
                tt[i] = j;
                break;
            }
            continue;
        }
        int ind = -1;
        for (int j = 0; j < n; j++){
            if (used[j]){continue;}
            if (a[j] != pr){ind = j;break;}
        }
        if (ind == -1){f = 1;i--;continue;}
        used[ind] = 1;
        pr = a[ind];
        pos[ind] = i;
        tt[i] = ind;
    }
    while (q--){
        int t;
        cin >> t;
        if (t == 1){
            int x;
            cin >> x;
            x--;
            used.assign(n, 0);
            swap(a[x], a[x + 1]);
            for (int i = 0; i < min(pos[x], pos[x + 1]); i++){
                used[tt[i]] = 1;
            }
            int pr = -1, f = 0, i = min(pos[x], pos[x + 1]);
            if (min(pos[x], pos[x + 1]) > 0){pr = a[tt[min(pos[x], pos[x + 1]) - 1]];}
            for (int _ = 0; _ < 10; _++){
                if (f){
                    for (int j = 0; j < n; j++){
                        if (used[j]){continue;}
                        pos[j] = i;
                        tt[i] = j;
                        break;
                    }
                    continue;
                }
                int ind = -1;
                for (int j = 0; j < n; j++){
                    if (used[j]){continue;}
                    if (a[j] != pr){ind = j;break;}
                }
                if (ind == -1){f = 1;continue;}
                used[ind] = 1;
                pr = a[ind];
                pos[ind] = i;
                tt[i] = ind;
                i++;
                if (i >= n){break;}
            }
        }
        else{
            int x;
            cin >> x;
            x--;
            cout << pos[x] + 1 << "\n";
        }
    }
}



