#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <experimental/random>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
using str = string;
using ld = long double;
const ll INF = 1e18, MOD = 998244353;
#define int long long
const int N = 600;
int c[N][N];
int binp(int v,int x) {
    if (x == 0) {
        return 1;
    }
    auto w = binp(v, x / 2);
    if (x % 2) {
        return w * w % MOD * v % MOD;
    }
    return w * w % MOD;
}

void solve();

signed main() {
    c[0][0] = 1;
    for (int i = 1; i < N; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (j > 0) {
                c[i][j] += c[i - 1][j - 1];
            }
            if (j != i) {
                c[i][j] += c[i - 1][j];
            }
            c[i][j] %= MOD;
        }
    }
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--) {
        solve();
        //cout << "\n";
    }
}

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    vector<set<int> > t(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        t[a[i]].insert(i);
    }
    for (int i = 0; i < q; ++i) {
        int T, p;
        cin >> T >> p;
        if (T == 1) {
            p--;
            if (a[p] != a[p + 1]) {
                t[a[p]].erase(p);
                t[a[p + 1]].insert(p);
                t[a[p + 1]].erase(p + 1);
                t[a[p]].insert(p + 1);
                swap(a[p], a[p + 1]);
            }
        } else {
            p--;
            set<int> mn;
            for (int i = 1; i <= n; ++i) {
                if (t[i].size() >= 1) {
                    mn.insert(*t[i].begin());
                }
            }
            int cur = 0;
            pair<int,int> pr = {-1, -1};
            while (true) {
                cur++;
                auto k = *mn.begin();
                if (k == p) {
                    cout << cur << "\n";
                    break;
                }
                mn.erase(k);
                if (pr.first != -1) {
                    auto it = t[pr.first].upper_bound(pr.second);
                    if (it != t[pr.first].end()) {
                        mn.insert(*it);
                    }
                }
                pr = {a[k], k};
                if (mn.size() == 0) {
                    auto it = t[pr.first].upper_bound(pr.second);
                    if (it != t[pr.first].end()) {
                        mn.insert(*it);
                    }
                }
            }
        }
    }
}
