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

constexpr int MAXN = 1e6 + 5;
int a[MAXN];
bool deq[MAXN];
int n, q;
vector <int> func(){
    int cnt = 1;
    queue <pair <int, int>> dq;
    int last = a[0];
    vector <int> ans(n);
    ans[0] = 1;
    for (int i = 1; i < n; i++){
        if (dq.size() == 0){
            if (last != a[i]){
                ans[i] = ++cnt;
            }
            else{
                dq.push({a[i], i});
                deq[i] = true;
            }
        }
        else{
            pair <int, int> x = dq.front();
            if (x.first != last){
                ans[x.second] = ++cnt;
                if (a[i] != x.first){
                    ans[i] = ++cnt;
                }
                else{
                    dq.push({a[i], i});
                    deq[i] = true;
                }
                dq.pop();
            }
            else{
                if (last !=a[i]){
                    ans[i] = ++cnt;
                }
                else{
                    dq.push({a[i], i});
                    deq[i] = true;
                }
            }
        }
        last = a[i];
    }
    while (dq.size() != 0){
        ans[dq.front().second] = ++cnt;
        dq.pop();
    }
    return ans;
}
void solve(){
    cin >> n >> q;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector <int> ans = func();

    while (q--){
        int t;
        cin >> t;
        int x;
        cin >> x;
        x--;
        if (t == 1){
            if (a[x] == a[x + 1]){
                continue;
            }
            swap(ans[x], ans[x + 1]);

        }
        else{
            cout << ans[x] << '\n';
        }
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    while (t--){
        solve();
    }
}

