#include <bits/stdc++.h>

using namespace std;

using ld = long double;
using ll = long long;




void solve() {
    int n, q;
    cin >> n >> q;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map <int, set <int>> f;
    for (int i = 0; i < n; i++) {
        f[a[i]].insert(i);
    }
    // for (auto [x, y] : f) {
    //     cout << x << " ";
    //     for (auto i : y) {
    //         cout << i << " ";
    //     }
    //     cout << endl;
    // }
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            x--;
            f[a[x]].erase(x);
            f[a[x + 1]].erase(x + 1);
            swap(a[x], a[x + 1]);
            f[a[x]].insert(x);
            f[a[x + 1]].insert(x + 1);
        }
        else {
            int y;
            cin >> y;
            y--;
            map <int, set <int>> go = f;
            map <int, int> ans;
            int last = -1;
            int cnt = 1;
            for (int j = 0; j < n; j++) {
                if (last == -1) {
                    last = a[j];
                    cnt++;
                    go[a[j]].erase(j);
                }
                else {
                    int fl = 0, mni = 1e9;
                    for (auto [x, y] : go) {
                        if (!y.empty() and x != last) {
                            //cout << x << endl;
                            if (*y.begin() < mni) {
                                fl = x;
                                mni = *y.begin();
                            }
                        }
                    }
                    //cout << endl;
                    //cout << mni << endl;
                    if (!fl) {
                        int fl2 = 0;
                        for (auto [x, y] : go) {
                            if (!y.empty()) {
                                fl2 = x;
                            }
                        }
                        for (auto k : go[fl2]) {
                            ans[k] = cnt++;
                        }
                        break;
                    }
                    else {
                        last = fl;
                        ans[*go[fl].begin()] = cnt++;
                        go[fl].erase(go[fl].begin());
                    }
                }
                //cout << last << endl;
            }
            cout << ans[y] << endl;
        }
    }
}


signed main() {
# ifdef  LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int enter = 1;
    // cin >> enter;
    while (enter--) {
        solve();
    }
}