#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
mt19937 rnd(239);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, q, ty, x, uk1, uk2, cnt; cin >> n >> q;
    vector <int> a(n), used(n, -1);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < q; i++) {
        cin >> ty >> x; x--;
        if (ty == 1) swap(a[x], a[x + 1]);
        if (ty == 2) {
            if (x == 0) {
                cout << "1\n";
                continue;
            }
            uk1 = uk2 = 0;
            cnt = 1;
            used[uk1] = i;
            while (true) {
                while (uk1 < n && (used[uk1] == i || a[uk1] == a[uk2])) {
                    uk1++;
                }
                if (uk1 == n) {
                    while (true) {
                        while (uk2 < n && used[uk2] == i) uk2++;
                        used[uk2] = i;
                        cnt++;
                        if (uk2 == x) {
                            cout << cnt << "\n";
                            break;
                        }
                    }
                    break;
                }
                cnt++;
                if (uk1 == x) {
                    cout << cnt << "\n";
                    break;
                }
                used[uk1] = i;
                swap(uk1, uk2);
            }
        }
    }
    return 0;
}
