#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;
set<int> st;

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

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;
            deque<pll> k;
            l = 1;
            for (i = 1; i <= n; i++) {
                if (a[i] != a[i + 1]) {
                    k.pb({l, i});
                    l = i + 1;
                }
            }
            int x = 0;
            cnt = 1;
            while (!k.empty()) {
                Try(k);
                if ((int)(k.size()) == 1) {
                    if (k[0].fi == h) {
                        cout << cnt << endl;
                        break;
                    }
                    k[0].fi++;
                } else {
                    auto to = k[0], to1 = k[1];
                    k.pop_front();
                    k.pop_front();
                    if (a[to.fi] != x) {
                        if (to.fi == h) {
                            cout << cnt << endl;
                            break;
                        }
                        x = a[to.fi];
                        to.fi++;
                    } else {
                        if (to1.fi == h) {
                            cout << cnt << endl;
                            break;
                        }
                        x = a[to1.fi];
                        to1.fi++;
                    }
                    if (to1.fi <= to1.se) k.push_front(to1);
                    if (to.fi <= to.se) k.push_front(to);
                }
                cnt++;
            }
        }
    }
    return 0;
}
