#include<bits/stdc++.h>
#define all(p) p.begin(),p.end()
using namespace std;
signed main() {
    int n;
    cin >> n;
    int q;
    cin >> q;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            swap(a[x], a[x + 1]);
        } else {
            int x;
            cin >> x;
            vector<int>ans = {1};
            vector<int>lf;
            for (int i = 2; i <= n; i++) {
                lf.push_back(i);
            }
            reverse(all(lf));
            for (int i = 2; i <= n; i++) {
                int p = lf.size() - 1;
                while (p >= 0 && a[lf[p]] == a[ans.back()]) {
                    p--;
                }
                if (p == -1) {
                    ans.push_back(lf.back());
                    lf.pop_back();
                } else {
                    ans.push_back(lf[p]);
                    lf.erase(lf.begin() + p);
                }
            }
            for (int j = 0; j < ans.size(); j++) {
                if (ans[j] == x) {
                    cout << j + 1 << endl;
                    break;
                }
            }
        }
    }
}