#include <bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;

vector<int> calcans(vector<int> a) {
    int n = a.size();
    vector<int> ans;
    vector<int> used(n);
    ans.emplace_back(0);
    used[0] = 1;
    for(int i = 1; i < n; ++i) {
        if(used[i]) {
            continue;
        }
        if(a[i] == a[ans.back()]) {
            for(int j = i; j < n; ++j) {
                if(a[i] != a[j] && !used[j]) {
                    ans.emplace_back(j);
                    used[j] = 1;
                    break;
                }
            }
        }
        ans.emplace_back(i);        
    }
    vector<int> pipisa(n);
    for(int i = 0; i < n; ++i) {
        pipisa[ans[i]] = i + 1;
    }
    return pipisa;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int n,q;
    cin >> n >> q;
    vector<int> a(n);
    for(int i= 0; i < n; ++i) {
        cin >> a[i];        
    }
    vector<int> ans = calcans(a);
    for(int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if(t == 1) {
            int x;
            cin >> x;
            swap(a[x], a[x-1]);
            if(a[x] != a[x-1]) {                
                ans = calcans(a);
            }
        } else {
            int y;
            cin >> y;
            y--;
            cout << ans[y] << '\n';
        }
    }
    return 0;
}