#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, q; cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> calc(n);
    deque<int> st; int t = 0; int prev=  -1;
    for (int i = 0; i < n; i++) {
        if (a[i] != prev && st.empty()) {
            calc[i] = t++;
            prev = a[i];
        } else if (a[i] == prev || a[st.back()] == a[i]) {
            st.push_back(i); continue;
        } else {
            calc[i] = t++;
            calc[st.front()] = t++;
            st.pop_front();
        }
    }
    for (int j = 0; j < st.size(); j++) {
        calc[st[j]] = t++;
    }
    while (q--) {
        int t; cin >> t;
        int x; cin >> x;
        if (t == 1) {
            x--; swap(a[x], a[x + 1]);
            deque<int> st; int t = 0; int prev=  -1;
            for (int i = 0; i < n; i++) {
                if (a[i] != prev && st.empty()) {
                    calc[i] = t++;
                    prev = a[i];
                } else if (a[i] == prev || a[st.back()] == a[i]) {
                //    cout << "!" << i << endl;
                    st.push_back(i); continue;
                } else {
                    calc[i] = t++;
                    calc[st.front()] = t++;
                    st.pop_front();
                }
            }
            for (int j = 0; j < st.size(); j++) {
                calc[st[j]] = t++;
            }
          //  for (auto x : calc) cout << x << ' ';
          //  cout << endl; 
        } else {
            cout << calc[x - 1] + 1 << '\n';
        }
    }
    return 0;
}