#include <bits/stdc++.h>
#include <experimental/random>

using namespace std;
using ll = long long;
using ld = long double;

const ll INF = 2e18, MOD = 998244353;

void solve();

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
}

void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    while (q--) {
        ll t, x;
        cin >> t >> x;
        x--;
        if (t == 1) {
            swap(a[x], a[x + 1]);
            continue;
        }

        ll pred = -1;
        vector<ll> used(n);
        ll col = 0;
        while (true) {
            ll nw = -1;
            for (int i = 0; i < n; i++) {
                if (a[i] != pred && !used[i]) {
                    nw = i;
                    break;
                }
            }
            if (nw == -1) {
                for (int i = 0; i < n; i++) {
                    if (!used[i]) {
                        nw = i;
                        break;
                    }
                }
            }

            col++;
            used[nw] = 1;
            pred = a[nw];
            if (nw == x) {
                break;
            }
        }
        cout << col << '\n';
    }
}