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

#define int long long
#define pb push_back
#define endl "\n"
using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename t>
istream& operator>>(istream &in, vector<t> &a){
    for (auto &el : a){
        in >> el;
    }
    return in;
}

template <typename t>
ostream& operator<<(ostream &out, vector<t> &a){
    for (auto &el : a){
        out << el << " ";
    }
    return out;
}

vector<int> get(int n, vector<int> a){
    vector<int> ans(n);
    set<int> active;
    int cnt = 0;
    int i = 0;
    int last = 0;
    int color = 0;
    while (cnt < n){
        if (!active.empty() && color != last || i == n){
            int j = *active.begin();
            active.erase(j);
            ans[j] = cnt++;
            last = a[j];
            continue;
        }
        if (a[i] != last){
            ans[i] = cnt++;
            last = a[i];
            i++;
            continue;
        } else{
            if (active.empty()){
                color = a[i];
                active.insert(i);
                i++;
                continue;
            } else{
                active.insert(i);
                i++;
                continue;
            }
        }
    }
    return ans;
}


void solve(){
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i){
        cin >> a[i];
    }
    vector<int> ans = get(n, a);
    int f = 1;
    while (q--){
        int t;
        cin >> t;
        if (t == 1){
            int x;
            cin >> x;
            x--;
            if (a[x] == a[x + 1]) continue;
            swap(a[x], a[x + 1]);
            swap(ans[x], ans[x + 1]);
            // f = 0;
            // ans = get(n, a);
        } else{
            int y;
            cin >> y;
            // if (!f){
            //     f = 1;
            //     ans = get(n, a);
            // }
            cout << ans[y - 1] + 1 << endl;
        }
    }
}


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