#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 5e3 + 11;
const int mod = 998244353;

signed main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1);
    int mxval = 0;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    while (q--) {
        int t, x; cin >> t >> x;
        if (t == 1) swap (a[x], a[x + 1]);
        else {
            vector<deque<int>> st(n + 1);
            int last =-1;
            set<int> S;
            for (int i = 1; i <= n; ++i) {
                st[a[i]].push_back(i);
            }
            for (int i = 1; i <= n; ++i) if ((int)st[i].size()) S.insert(st[i].front());
            for (int lvl = 1; lvl <= n; ++lvl) {
                auto opt = S.begin();
                if (a[*opt] == last) ++opt;
                if (opt == S.end()) --opt;
                int w = (*opt);
                if (st[a[w]].front() == x) {
                    cout << lvl << '\n';
                    break;
                }
                st[a[w]].pop_front();
                last = a[w];
                S.erase (opt);
                if ((int)st[a[w]].size()) S.insert (st[a[w]].front());
            }
        }
    }

}

