#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops");
#pragma GCC target("avx2");

// #define int int_fast64_t
#define ull unsigned long long
#define all(x) x.begin(), x.end()
mt19937 rng(127);

constexpr int MAXN = 1e4 + 1, INF = 2e9, MOD = 998244353, k1 = 31;
// constexpr int interesno_zabanyat_li_menya_prosto_za_stroku_v_reshenii_MOD = 435397531;

alignas(64) pair<int, int> tree[4 * MAXN];
alignas(64) int ans[MAXN];


void build(int v, int l, int r) {
    if (r - l == 1) {
        tree[v].second = l;
        return;
    }
    int mid = (l + r) >> 1;
    build((v << 1), l, mid);
    build((v << 1) | 1 , mid, r);
    tree[v] = min(tree[v << 1], tree[(v << 1) | 1]);
}

void upd(int i, int x, int v, int l, int r) {
    if (r - l == 1) {
        tree[v].first = x;
        return;
    }
    int mid = (l + r) >> 1;
    if (i < mid) {
        upd(i,x,v << 1, l, mid);
    } else {
        upd(i,x,(v << 1) | 1, mid, r);
    }
    tree[v] = min(tree[v << 1], tree[(v << 1) | 1]);
}

constexpr pair<int, int> neu = {INF, INF}, fil = {0,0};
const queue<int> qqq;

pair<int, int> get(int ql, int qr, int v, int l, int r) {
    if (l >= ql && r <= qr) {
        return tree[v];
    }
    if (l >= qr || r <= ql) {
        return neu;
    }
    int mid = (l + r) >> 1;
    return min(get(ql,qr,(v << 1), l, mid), get(ql,qr,(v << 1) | 1, mid, r));
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    queue<int> e, o;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int pred = 1;
    vector<queue<int>> que(n + 1);
    build(1,0,n + 1);
    while (q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int x;
            cin >> x, x--;
            swap(a[x], a[x + 1]);
        } else {
            if (pred == 1) {
                fill(tree, tree + 4 * MAXN, fil);
                fill(ans, ans + MAXN, 0);
                fill(all(que), qqq);
                build(1,0,n + 1);
                for (int i = 0; i < n; i++) {
                    que[a[i]].push(i);
                }
                for (int i = 0; i <= n; i++) {
                    que[i].push(INF);
                }
                for (int i = 0; i <= n; i++) {
                    upd(i,que[i].front(), 1,0,n + 1);
                }
                int lst = 0, p = 0;
                while (true) {
                    pair<int, int> z = get(0,lst,1,0,n + 1);
                    z = min(z,get(lst + 1,n + 1,1,0,n + 1));
                    if (z.first == INF) {
                        break;
                    }
                    ans[z.first] = p;
                    lst = z.second;
                    p++;
                    que[z.second].pop();
                    upd(z.second,que[z.second].front(), 1,0,n + 1);
                }
                pair<int, int> z = get(0,n + 1,1,0,n + 1);
                if (z.first != INF) {
                    while (que[z.second].front() != INF) {
                        ans[que[z.second].front()] = p;
                        que[z.second].pop();
                        p++;
                    }
                }
            }
            int y;
            cin >> y, y--;
            cout << ans[y] + 1 << '\n';
        }
        pred = type;
    }
    return 0;
}
