#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    while (m--) {
        int type;
        cin >> type;
        if (type == 1) {
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        }
        else {
            int y;
            cin >> y;
            y--;
            int qcolor = -1;
            int lastcolor = -1;
            queue<int> q;
            int timer = 0;
            int ans = -1;
            for (int i = 0; i < n; i++) {
                if (lastcolor != qcolor && !q.empty()) {
                    timer++;
                    int cur = q.front();
                    q.pop();
                    if (cur == y) {
                        ans = timer;
                        break;
                    }
                    lastcolor = qcolor;
                    if (q.empty()) qcolor = -1;
                }
                if (a[i] == lastcolor) {
                    qcolor = a[i];
                    q.push(i);
                }
                else {
                    timer++;
                    lastcolor = a[i];
                    if (i == y) {
                        ans = timer;
                        break;
                    }
                }
            }
            while (!q.empty()) {
                timer++;
                int cur = q.front();
                q.pop();
                if (cur == y) {
                    ans = timer;
                    break;
                }
            }
            cout << ans << "\n";
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}