#include <bits/stdc++.h>
#include <random>

#define i128 __int128
// #define int long long

using namespace std;

random_device lal;
mt19937 rnd(lal());


const int inf = 1e18, mod = 998'244'353;
const int sg_base = 524288, sg_size = sg_base * 2 - 1;


signed main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n), cnts(n + 1);
    set<int> b;
    for (int &i: a) {
        cin >> i;
        cnts[i]++;
        b.insert(i);
    }
    vector<vector<int> > data(n + 1);
    for (int j: b) {
        for (int i = 0; i < n; ++i) {
            if (a[i] != j) {
                data[j].push_back(i);
            }
        }
    }

    while (q--) {
        int t, x, y;
        cin >> t;
        if (t == 1) {
            cin >> x;
            --x;
            swap(a[x], a[x + 1]);
        } else {
            cin >> y;
            --y;
            vector<int> did(n + 1);
            vector<bool> used(n + 1);
            used[0] = true;
            int last = a[0], cnt = 1;
            if (y == 0) {
                cout << 1 << '\n';
                continue;
            }
            while (true) {
                if (data[last].size() <= did[last]) {
                    int hm = 0;
                    for (int i = 0; i < n; ++i) {
                        if (a[i] == last) { ++hm; }
                        if (i == y) {
                            cout << n - cnts[last] + hm << '\n';
                            break;
                        }
                    }
                    break;
                }
                int cur = data[last][did[last]];
                ++did[last];
                if (used[cur]) { continue; }
                used[cur]=true;
                ++cnt;
                if (cur == y) {
                    cout << cnt << '\n';
                    break;
                }
                last = a[cur];
            }
        }
    }
}
