#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<ll> get(ll n, vector<ll> &a) {
    vector<ll> pos(n);
    ll prev = a[0];
    vector<bool> used(n);
    used[0] = 1;
    ll cur = 1;
    while (cur < n) {
        bool f = 0;
        ll first = 1e9l;
        for (ll i = 0; i < n; i++) {
            if (!used[i]) continue;
            first = min(first, i);
            if (a[i] != prev) {
                pos[i] = cur;
                cur++;
                prev = a[i];
                f = 1;
                break;
            }
        }
        if (!f) {
            for (ll i = first; i < n; i++) {
                if (used[i]) continue;
                pos[i] = cur;
                cur++;
            }
            break;
        }
    }
    return pos;
}

int main() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (auto &i : a) cin >> i;
    vector<ll> pos = get(n, a);
    while (q--) {
        ll ord;
        cin >> ord;
        if (ord == 1) {
            ll x;
            cin >> x;
            swap(a[x - 1], a[x]);
            pos = get(n, a);
        } else {
            ll y;
            cin >> y;
            y--;
            cout << pos[y] + 1 << '\n';
        }
    }
}

