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

vector<ll> init(vector<ll>& a) {
    ll n = (int)a.size();
    vector<ll> ans(n);
    ll l1 = 0, l2 = 0;
    ll col = 0;
    while (l1 < n) {

        col++;
        ans[l1] = col;

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

        col++;
        ans[l2] = col;

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

    for (int i = 0; i < n; i++) {
        if (!ans[i]) {
            col++;
            ans[i] = col;
        }
    }
    return ans;
}

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

        cout << ans[x] << '\n';
    }
}