#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll

#pragma gcc optimize("O3")
#pragma gcc target("avx3,avx2")


using pii = pair<int, int>;

vector<int> get_pos(const vector<int> &a){
    int n = a.size();
    deque<int> dq;
    int last = -1;
    vector<int> res;
    for(int i = 0; i < n; i++){
        if(a[i] == last){
            dq.push_back(i);
            continue;
        }
        res.push_back(i);
        last = a[i];
        while(dq.size() && a[dq.front()] != last){
            res.push_back(dq.front());
            last = a[dq.front()];
            dq.pop_front();
        }
    }
    for(auto x : dq){
        res.push_back(x);
    }
    vector<int> pos(res.size());
    for(int i = 0; i < n; i++){
        pos[res[i]] = i + 1;
    }
    return pos;
}

void solve(){
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for(auto &x : a){
        cin >> x;
    }
    bool need = true;
    vector<int> pos;
    while(q--){
        int t;
        cin >> t;
        if(t == 1){
            int i;
            cin >> i;
            swap(a[i], a[i - 1]);
            need = true;
        } else {
            if(need){
                pos = get_pos(a);
            }
            int i;
            cin >> i;
            i--;
            cout << pos[i] << '\n';
        }
    }
}

signed main(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}