#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 5e5 + 10;
int a[MAXN], ans[MAXN];
bool v[MAXN];
int n, q;

void solve() {
    fill(v + 1, v + n + 1, 0);

    int idx = 1;
    v[idx] = ans[idx] = 1;
    
    for (int cnt = 2; cnt <= n; cnt++) {
        int f = 0, g = 0;
        
        for (int i = n; i >= 1; i--) {
            if (v[i]) continue;
            g = i;
            if (a[i] == a[idx]) continue;
            f = i;
        }

        if (f) idx = f;
        else idx = g;

        v[idx] = 1;
        ans[idx] = cnt;
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> q;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    bool f = 0;

    while (q--) {
        int t, x;
        cin >> t >> x;

        if (t == 1) {
            swap(a[x], a[x + 1]);
            f = 0;
        } else {
            if (!f) {
                f = 1;
                solve();
            }
            
            cout << ans[x] << '\n';
        }
    }

    return 0;

}