#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;


#define rep(x) for (int rep_i = 0; rep_i < x; rep_i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
#define int long long
const ll MOD = 998244353;


mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int binpow(int a, int k) {
    if (k == 0)
        return 1;
    int b = binpow(a, k / 2);
    int z = (b * b) % MOD;
    if (k % 2 == 1)
        return (z * a) % MOD;
    return z;
}

void solve() {
    int n, qu;
    cin >> n >> qu;
    vector<int> a(n);
    rep(n)
        cin >> a[rep_i];
    rep(qu) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            swap(a[x - 1], a[x]);
        } else {
            int y;
            cin >> y;
            vector<vector<int> > s;
            int last = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] != a[last]) {
                    s.push_back({(i - 1) - last + 1, last});
                    last = i;
                }
            }
            s.push_back({(n - 1) - last + 1, last});

            if (s.size() == 1) {
                cout << y << endl;
                continue;
            }
            int i1 = 0, i2 = 1;
            int cnt1 = 0, cnt2 = 0;
            vector<int> ans(n, 0);
            last = -1;
            int time = 1;
            while (i2 < s.size()) {
                if (time == 1 || last != a[s[i1][1]]) {
                    ans[s[i1][1] + cnt1] = time;
                    cnt1++;
                    time++;
                    last = a[s[i1][1]];
                    if (cnt1 == s[i1][0]) {
                        swap(cnt1, cnt2);
                        swap(i1, i2);
                        i2 = i1 + 1;
                        cnt2 = 0;
                    }
                } else {
                    ans[s[i2][1] + cnt2] = time;
                    cnt2++;
                    time++;
                    last = a[s[i2][1]];
                    if (cnt2 == s[i2][0]) {
                        i2++;
                        cnt2 = 0;
                    }
                }
            }
            for (int i = s[i1][1] + cnt1; i < n; i++) {
                ans[i] = time;
                time++;
            }
            cout << ans[y-1] << endl;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(6);

    int mult = 1;
    //cin >> mult;
    while (mult--)
        solve();
    return 0;
}
