//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define ld long double
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define coutp cout << "       "
#define cont continue
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

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

template<typename T>
istream& operator>> (istream& in, pair<T, T>& a) {
    in >> a.F >> a.S;
    return in;
}

template<typename T>
ostream& operator<< (ostream& os, pair<T, T>& a) {
    os << a.F << " " << a.S;
    return os;
}

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

template<typename T>
ostream& operator<< (ostream& os, vector<T>& a) {
    for (auto& x : a) {
        os << x << " ";
    }
    return os;
}

constexpr int inf = 2e18, mod = 998244353;
constexpr ld eps = 1e-9;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int multitest = 1; //cin >> multitest;
    while (multitest--) {
        int n, q; cin >> n >> q;
        vector<int> a(n); cin >> a;
        vector<int> b = a;
        sort(all(b));
        b.erase(unique(all(b)));
        for (auto& x : a) {
            x = lower_bound(all(b), x) - b.begin();
        }
        vector<vector<int>> where;
        while (q--) {
            int type; cin >> type;
            int ind; cin >> ind; ind--;
            if (type == 1) {
                swap(a[ind], a[ind + 1]);
                cont;
            }
            int j = 0;
            //cout << next << endl;
            //coutp << a << endl;
            int last = -1;
            vector<bool> use(n);
            int t = 1;
            for (int i = 0; i < n;) {
                while (j < n - 1 and a[i] == a[j] or use[j]) {
                    j++;
                }
                if (a[i] == a[j] or use[j]) {
                    j = -1;
                }
                if (use[i]) {
                    i++;
                    cont;
                }
                int c = -1;
                if (a[i] != last) {
                    c = i;
                } else {
                    if (j == -1) {
                        c = i;
                    } else {
                        c = j;
                    }
                }
                //cout << i << " " << c << " " << t << endl;
                if (c == ind) {
                    cout << t << endl;
                    break;
                }
                t++;
                last = a[c];
                use[c] = 1;
                if (c == i) {
                    i++;
                }
            }
        }
    }
    return 0;
}

/*
10 10
1 2 2 2 3 4 5 6 7 8
2 1
1 1
2 2
1 2
2 3
1 3
2 4
1 4
2 3
2 5
*/
