#include <bits/stdc++.h>
using namespace std;
#define int int64_t
void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int qq = 0; qq < q; qq++) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            swap(a[x], a[x + 1]);
        }
        else {
            int y;
            cin >> y;
            int lst = -1, j1 = 1, j2 = 2;
            if (n == 1) {
                cout << 1 << '\n';
                continue;
            }
            vector<int> f(n + 1, -1);
            int tm = 0;
            while (j1 <= n) {
                while (true) {
                    if (f[j1] != -1) {
                        j1++;
                    }
                    else {
                        break;
                    }
                }
                if (j1 == j2) {
                    j2++;
                    while (j2 <= n) {
                        if (a[j2] != a[j1]) {
                            break;
                        }
                        j2++;
                    }
                }
                if (j1 > n) {
                    break;
                }
                if (j2 == n + 1) {
                    tm++;
                    f[j1] = tm;
                    lst = a[j1];
                    j1++;
                    continue;
                }
                if (lst != a[j1]) {
                    tm++;
                    f[j1] = tm;
                    lst = a[j1];
                    j1++;
                    continue;
                }
                else {
                    tm++;
                    f[j2] = tm;
                    lst = a[j2];
                    j2++;
                    while (j2 <= n && a[j2] == a[j1]) {
                        j2++;
                    }
                    continue;
                }
            }
            cout << f[y] << '\n';
        }
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}