#include <bits/stdc++.h>
using namespace std;
int n, q; 
vector<int> ans;
vector<int> a;
vector<bool> used;
void relax() {
    used.clear();
    used.assign(n, false);
    int now = 0;
    int cnt = 1;
    used[0] = true;
    ans[0] = 1;
    bool fl = true;
    while (fl && now < n) {
        fl = false;
        for (int i = 1; i < n; i++) {
            if (used[i]) continue;
            if (a[i] != a[now]) {
                fl = true;
                used[i] = true;
                cnt++;
                now = i;
                ans[now] = cnt;
                break;
            }
        }
    }
    if (!fl) {
        for (int i = 1; i < n; i++) 
        if (!used[i]) ans[i] = ++cnt;
    }
}
int main() {
    cin >> n >> q;
    a.assign(n, 0);
    ans.assign(n, 0);
    used.assign(n, false);
    for (auto& x : a) cin >> x;
    relax();
    while (q--) {
        int t; cin >> t;
        if (t == 2) {
            int y; cin >> y;
            cout << ans[y - 1] << "\n";
        } else {
            int x; cin >> x;
            swap(a[x], a[x - 1]);
            relax();
        }
    }
}