#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;
        }

        vector<ll> used(n);

        ll l1 = 0, l2 = 0;

        ll col = 0;
        while (l1 < n) {

            used[l1] = 1;
            col++;
            if (l1 == x) {
                cout << col << '\n';
            }

            while (l2 < n && (a[l2] == a[l1] || used[l2])) {
                l2++;
            }
            if (l2 == n) break;

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

            while (l1 < n && (used[l1] == 1 || a[l1] == a[l2])) {
                l1++;
            }
        }

        for (int i = 0; i < n; i++) {
            if (!used[i]) {
                col++;
                if (i == x) {
                    cout << col << '\n';
                }
            }
        }
    }
}