#include <bits/stdc++.h>

using namespace std;


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

    int n, q;

    cin >> n >> q;

    vector<int> lst_els(n, 0);

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

    vector<int> near_not_eq(n, n);
    vector<bool> used(n, false);

    int j=0;

    int last1 = -1;
    for (int i = 0; i < n; ++i){
        if (used[i]){
            continue;
        }
        if (lst_els[i] != last1){
            j++;
            last1 = lst_els[i];
            continue;
        }
        while (j < n && lst_els[j] == lst_els[i]){
            j++;
        }

        if (j >= n){
            break;
        }

        near_not_eq[i] = j;
        used[j] = true;
        last1 = lst_els[i];
        j++;
    }

    for (int k = 0; k < q; ++k){
        int type;

        cin >> type;

        if (type == 1){
            int ind;
            cin >> ind;
            ind--;
            swap(lst_els[ind], lst_els[ind+1]);
            near_not_eq = vector<int>(n, n);
            vector<bool> used2(n, false);
            int j=0;

            int last2 = -1;
            for (int i = 0; i < n; ++i){
                if (used2[i]){
                    continue;
                }
                if (lst_els[i] != last2){
                    j++;
                    last2 = lst_els[i];
                    continue;
                }
                while (j < n && lst_els[j] == lst_els[i]){
                    j++;
                }

                if (j >= n){
                    break;
                }

                near_not_eq[i] = j;
                used[j] = true;
                last2 = lst_els[i];
                j++;
            }
        } else {
            int ind;
            cin >> ind;
            ind--;

            int last = -1;
            vector<int> ans(n, -1);
            int cnt_process = 0;
            vector<int> to_proc;
            vector<int> path;

            for (int i = 0; i < n; ++i){
                if (ans[i] != -1){
                    continue;
                }

                if (lst_els[i] != last){
                    cnt_process++;
                    ans[i] = cnt_process;
                    last = lst_els[i];
                } else {
                    if (near_not_eq[i] == n){
                        to_proc.push_back(i);
                    } else {
                        cnt_process++;
                        ans[near_not_eq[i]] = cnt_process;
                        cnt_process++;
                        ans[i] = cnt_process;
                        last = lst_els[i];
                    }
                }
            }

            for (int el: to_proc){
                cnt_process++;
                ans[el] = cnt_process;
                path.push_back(lst_els[el]);
            }

            cout << ans[ind] << "\n";
        }
    }
}