#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, q, a[500002], j, i, x, lst, out[500002];
deque<ll> d;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> q;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
    }
    j = 0;
    lst = 0;
    i = 1;
    while (j != n) {
        if (!d.empty() && a[d.front()] != lst) {
            j++;
            out[d.front()] = j;
            lst = a[d.front()];
            d.pop_front();
        } else if (i <= n && a[i] == lst) {
            d.push_back(i);
            i++;
        } else if (i <= n) {
            j++;
            lst = a[i];
            out[i] = j;
            i++;
        } else {
            while (!d.empty()) {
                j++;
                out[d.front()] = j;
                lst = a[d.front()];
                d.pop_front();
            }
        }
    }
    while (q--) {
        cin >> x;
        if (x == 1) {
            cin >> x;
            swap(out[x], out[x + 1]);
        } else {
            cin >> x;
            cout << out[x] << '\n';
        }
    }
    return 0;
}
