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

int main() {
    int n, q; cin >> n >> q;
    vector<int> a(n); for (int &ai: a) cin >> ai;
    
    set<int> p;
    for (int i = 1; i < n; i++) p.insert(i);

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

        if (t == 1) { swap(a[x], a[x+1]); continue; }

        
        int pc = a[0];
        set<int> c = p;
        
        if (x == 0) { cout << "1\n"; continue; }
        
        for (int i = 2; i <= n; i++) {
            int j = -1;
            for (int ci: c) if (a[ci] != pc) { j = ci; break; }
            if (j == -1) j = *c.begin();
            pc = a[j];
            c.erase(j);
            
            if (j == x) {
                cout << i << "\n";
                break;
            }
        }
    }
}
