#include <bits/stdc++.h>

using namespace std;

void add(vector<vector<int>> &idxs, vector<int> &a, int idxi, int idxj) {
    int i = 0;
    while (i < (int)idxs[a[idxi]].size() && idxs[a[idxi]][i] < idxi) i++;
    idxs[a[idxi]].erase(idxs[a[idxi]].begin() + i);
    i = 0;
    while (i < (int)idxs[a[idxj]].size() && idxs[a[idxj]][i] < idxi) i++;
    idxs[a[idxj]].insert(idxs[a[idxj]].begin() + i, idxi);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    vector<vector<int>> idxs(n);
    for (int i = 0; i < n; i++) {
        idxs[a[i]].push_back(i);
    }
    for (int _ = 0; _ < q; _++) {
        int t;
        cin >> t;
        if (t == 1) {
            int idx;
            cin >> idx; idx--;
            add(idxs, a, idx, idx + 1);
            add(idxs, a, idx + 1, idx);
            swap(a[idx], a[idx + 1]);
        } else {
            set<pair<int, int>> s;
            vector<int> p(n, 0);
            for (int i = 0; i < n; i++) {
                if (!idxs[i].empty()) {
                    s.insert({idxs[i].front(), i});
                }
            }
            vector<int> ans(n);
            int cur = 1;
            int last = -1;
            while (!s.empty()) {
                auto [idx, c] = *s.begin();
                s.erase(s.begin());
                ans[idx] = cur;
                cur++;
                if (last != -1) {
                    if (p[last] != idxs[last].size()) s.insert({idxs[last][p[last]], last});
                }
                last = c;
                p[last]++;

            }
            while (p[last] != idxs[last].size()) {
                ans[idxs[last][p[last]]] = cur;
                cur++;
                p[last]++;
            }
            int v;
            cin >> v;
            v--;
            cout << ans[v] << endl;
        }
    }
    return 0;
}
