#include<bits/stdc++.h>

using namespace std;

int get(vector<int>&a, int pos){
    int n = (int)a.size();
    vector<int> res(n);
    res[0] = 0;
    vector<int> order = {a[0]};
    deque<int> add;
    int pointer = 1;
    while (true) {
        if(!add.empty() && a[add[0]]!=order.back()){
            res[add[0]] = order.size();
            order.push_back(a[add[0]]);
            add.pop_front();
            continue;
        }
        if(pointer<n && a[pointer]!=order.back()){
            res[pointer] = order.size();
            order.push_back(a[pointer]);
            pointer++;
            continue;
        }
        if(pointer<n){
            add.push_back(pointer);
            pointer++;
            continue;
        }
        break;
    }
    for (auto elem : add){
        res[elem] = order.size();
        order.push_back(elem);
    }
    return res[pos]+1;
}

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i<n; i++){
        cin >> a[i];
    }
    for (int i = 0; i<q; i++){
        int t, p;
        cin >> t >> p;
        p--;
        if(t == 1){
            swap(a[p], a[p+1]);
        }
        else{
            cout << get(a, p) << endl;
        }
    }
}

