#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int A = 1e4 + 5;
const int MOD = 998244353;


ll n, q, tp, i, x, a[A], l, cnt = 1, h, fl[A];
deque<int> st;


void Try(deque<pll> k) {
    while ((int)k.size() > 1) {
        auto to = k[0];
        auto to1 = k[1];
        k.pop_front();
        k.pop_front();
        if (a[to.fi] == a[to1.fi]) {
            to.se = to1.se;
            k.push_front(to);
        } else {
            k.push_front(to1);
            k.push_front(to);
            break;
        }
    }
}

void f(int x) {
    int i, j, l = 1, ls, fl, cnt = 1;
    deque<pll>k;
    for (i = 1; i <= n; i++) {
        if (a[i] != a[i + 1]) {
            k.pb({l, i});
            l = i + 1;
        }
    }
    for (i = 1; i <= n; i++) {
        Try(k);
        if ((int)k.size() == 1) {
            if (k[0].fi == x) {
                cout << cnt << endl;
            }
            k[0].fi++;
            cnt++;
        } else {
            auto to = k[0], to1 = k[1];
            k.pop_front();
            k.pop_front();
            if (a[to.fi] != ls) {
                if (to.fi == h) {
                    cout << cnt << endl;
                    return;
                }
                ls = a[to.fi];
                to.fi++;
                cnt++;
            } else {
                 if (to1.fi == h) {
                    cout << cnt << endl;
                    return;
                }
                ls = a[to1.fi];
                to1.fi++;
                cnt++;
            }
            if (to1.fi <= to1.se) k.push_front(to1);
            if (to.fi <= to.se)  k.push_front(to);

        }
    }
}

int32_t main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // LOCAL

    cin >> n >> q;
    for (i = 1; i <= n; i++) cin >> a[i];

    while (q--) {
        cin >> tp;
        if (tp == 1) {
            cin >> x;
            swap(a[x], a[x + 1]);
        } else {
            cin >> h;
            f(h);
        }
    }
    return 0;
}
