#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair<int, int>

using namespace std;

void solve() {
    int n, q; cin >> n >> q;
    vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> next(n, n);
    vector<int> last(n + 1, n);
    for (int i = n - 1; i >= 0; i--) {
        next[i] = last[a[i]];
        last[a[i]] = i;
    }
    set<pii> s;
    vector<int> is(n + 1, 0);
    for (int i = 0; i < n; i++) {
        if (!is[a[i]]) {
            is[a[i]] = 1;
            s.insert({i, a[i]});
        }
    }
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x; cin >> x; x--;
            swap(a[x], a[x + 1]);
            next.assign(n, n);
            last.assign(n + 1, n);
            for (int i = n - 1; i >= 0; i--) {
                next[i] = last[a[i]];
                last[a[i]] = i;
            }
        } else {
            int x; cin >> x; x--;
            set<pii> s;
            vector<int> is(n + 1, 0);
            for (int i = 0; i < n; i++) {
                if (!is[a[i]]) {
                    is[a[i]] = 1;
                    s.insert({i, a[i]});
                }
            }
            int cur = -1;
            int cnt = 1;
            while (true) {
                auto [pos, col] = *s.begin();
                if (col == cur && (int) s.size() > 1) {
                    auto it = s.begin();
                    it++;
                    auto [pos2, col2] = *it;
                    pos = pos2;
                    col = col2;
                }
                if (pos == x) {
                    cout << cnt << '\n';
                    break;
                }
                s.erase({pos, col});
                if (next[pos] != n) s.insert({next[pos], col});
                cnt++;
                cur = col;
            }
        }
    }
}

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