#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll infll = 1e18;

template<typename T>
istream &operator>>(istream &is, vector<T> &a) {
    for (auto &i : a) {
        is >> i;
    }
    return is;
}

int32_t main() {
#ifdef LOCAL
    freopen("C:\\work\\input.txt", "r", stdin);
#else
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    cin >> a;
    for (auto &i : a) {
        --i;
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            cin >> i;
            --i;
            swap(a[i], a[i + 1]);
        } else {
            int y;
            cin >> y;
            --y;
            vector<vector<int>> ind(n);
            for (int i = n - 1; i >= 0; --i) {
                ind[a[i]].push_back(i);
            }
            if (y == 0) {
                cout << 1 << "\n";
                continue;
            }
            priority_queue<int, vector<int>, greater<>> pq;
            for (int i = 0; i < n; ++i) {
                if (!ind[i].empty()) {
                    pq.push(ind[i].back());
                }
            }
            vector<bool> used(n);
            int cur = a[0];
            used[ind[cur].back()] = 1;
            while (!pq.empty() && used[pq.top()]) {
                pq.pop();
            }
            ind[cur].pop_back();
            if (!ind[cur].empty()) {
                pq.push(ind[cur].back());
            }
            int pos = 2;
            bool ok = false;
            for (int i = 1; i < n; ++i) {
                if (!ind[cur].empty()) {
                    used[ind[cur].back()] = 1;
                    while (!pq.empty() && used[pq.top()]) {
                        pq.pop();
                    }
                }
                int mn = n;
                if (!pq.empty()) {
                    mn = pq.top();
                }
                if (!ind[cur].empty()) {
                    used[ind[cur].back()] = 0;
                    pq.push(ind[cur].back());
                }
                if (mn == n) {
                    break;
                }
                cur = a[mn];
                used[ind[cur].back()] = 1;
                while (!pq.empty() && used[pq.top()]) {
                    pq.pop();
                }
                if (ind[cur].back() == y) {
                    cout << pos << "\n";
                    ok = true;
                    break;
                }
                ind[cur].pop_back();
                if (!ind[cur].empty()) {
                    pq.push(ind[cur].back());
                }
                ++pos;
            }
            if (ok) {
                continue;
            }
            for (int i = (int)ind[cur].size() - 1; i >= 0; --i) {
                if (ind[cur][i] == y) {
                    cout << pos << "\n";
                    break;
                }
                ++pos;
            }
        }
    }
    return 0;
}
