#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    while (q--) {
        int c, x;
        cin >> c >> x;
        x--;
        if (c == 2) {
            vector<int> used(n);
            int pref = 0;
            int t = 0;
            vector<int> ans(n);
            int i1 = 1;
            while (pref != n) {
                //cout << t << ' ';
                int ind = t;
                for (int i = pref; i < n; ++i) {
                    if (used[i] == 0 && a[i] != a[t]) {
                        ind = i;
                        break;
                    }
                }
                if (ind == t) {
                    for (int i = 0; i < n; ++i) if (used[i] == 0) ans[i] = i1, i1++;
                    break;
                }
                used[t] = 1;
                ans[t] = i1;
                i1++;
                while (pref != n && used[pref]) pref++;
                t = ind;
            }
            //cout << endl;
            cout << ans[x] << '\n';
        }
        if (c == 1) {
            swap(a[x], a[x + 1]);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
}
