#pragma GCC optimize("O3,unroll-loops")
#include <string>
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>

using namespace std;

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

void Solve () {
    int n, q;
    cin >> n >> q;
    vector<int>a(n);
    for (int& i : a) {
        cin >> i;
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            --x;
            swap(a[x], a[x + 1]);
        }
        else {
            int x;
            cin >> x;
            --x;
            if (x == 0) {
                cout << 1 << '\n';
                continue;
            }
            int now = a[0];
            int cnt = 1;
            deque<int>c;
            bool flag = 0;
            for (int i = 1; i < n; ++i) {
                if (!c.empty() && now != a[c.front()]) {
                    cnt++;
                    if (c.front() == x) {
                        cout << cnt << '\n';
                        flag = 1;
                        break;
                    }
                    now = a[c.front()];
                    c.pop_front();
                }
                if (a[i] == now) {
                    c.push_back(i);
                }
                else {
                    cnt++;
                    if (i == x) {
                        cout << cnt << '\n';
                        flag = 1;
                        break;
                    }
                    now = a[i];
                }
            }
            if (flag) {
                continue;
            }
            for (int i : c) {
                cnt++;
                if (i == x) {
                    cout << cnt << '\n';
                    break;
                }
            }
        }
    }
}

signed main () {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        Solve();
    }
}