#include <bits/stdc++.h>

using namespace std;
using ll = long long;

signed main() {
    ll n, q;
    cin >> n >> q;
    vector<ll> v(n);
    for (ll i = 0; i < n; i++) cin >> v[i];
    while (q--) {
        ll t, x;
        cin >> t >> x;
        if (t == 1) {
            swap(v[x - 1], v[x]);
        } else {
            x--;
            ll cnt = 0, fl = -1;
            vector<bool> w(n);
            ll i = 0;
            while (i < n) {
                if (w[i]) {
                    i++;
                    continue;
                }
                ll ind = -1;
                for (ll j = i; j < n; j++) {
                    if (fl != v[j] && !w[j]) {
                        w[j] = true;
                        ind = j;
                        break;
                    }
                }
                if (ind == -1) {
                    w[i] = true;
                }
                cnt++;
                if (ind != -1) fl = v[ind];
                if (ind == x) {
                    break;
                }
            }
            cout << cnt << endl;
        }
    }
}
