#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")
// #pragma GCC optimize("unroll-loops")

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = 0; i < q; i++) {
        ll t, x;
        cin >> t >> x;
        if (t == 1) {
            swap(a[x - 1], a[x]);
        } else {
            set<ll> dq;
            for (ll j = 0; j < n; j++) {
                dq.insert(j);
            }
            ll last = -1;
            ll cnt = 0;
            bool f = true;
            while (f) {
                ll now = -1;
                for (auto j : dq) {
                    if (a[j] != last) {
                        last = a[j];
                        now = j;
                        if (j == x - 1) {
                            cout << cnt + 1 << '\n';
                            f = false;
                        }
                        cnt++;
                        break;
                    }
                }
                if (now == -1) {
                    now = *dq.begin();
                    last = a[now];
                    if (now == x - 1) {
                        cout << cnt + 1 << '\n';
                        break;
                    }
                    cnt++;
                }
                dq.erase(now);
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
