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

constexpr int MAXN = 1e6 + 5;
int a[MAXN];
int n, q;
int func(int x){
    int cnt = 1;
    deque <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_back({a[i], i});
                last = a[i];
            }
        }
        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_back({a[i], i});
                }
                dq.pop_front();
            }
            else{
                if (last !=a[i]){
                    ans[i] = ++cnt;
                }
                else{
                    dq.push_back({a[i], i});
                }
            }
        }
        last = a[i];
    }
    for (auto v: dq){
        ans[v.second] = ++cnt;
    }
    return ans[x];
}
void solve(){
    cin >> n >> q;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    while (q--){
        int t;
        cin >> t;
        int x;
        cin >> x;
        x--;
        if (t == 1){
            swap(a[x], a[x + 1]);
        }
        else{
            cout << func(x) << '\n';
        }
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    while (t--){
        solve();
    }
}
