#ifndef LOCAL
#pragma GCC optimize("O3,unroll-loops")
#endif

#include <bits/extc++.h>

using namespace std;

#define int long long
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()

int32_t main() {
#ifndef LOCAL
    cin.tie(nullptr), ios_base::sync_with_stdio(false);
#endif
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1), is(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    auto solve = [&](int y) {
        is.assign(n + 1, 0);
        int st = 1, next = 1, ans = 0, col = -1;
        while (true) {
            ans++;
            while (is[st]) st++;
            if (a[st] != col) {
                if (st == y) {
                    return ans;
                }
                is[st] = 1;
                col = a[st];
                continue;
            }
            while (next < n && (a[next] == a[st] || is[next])) next++;
            if (next == n) {
                break;
            }
            if (next == y) {
                return ans;
            }
            is[next] = 1;
            col = a[next];
        }
        while (true) {
            while (is[st]) st++;
            if (st == y) {
                return ans;
            }
            is[st] = 1;
            ans++;
        }
    };
    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            swap(a[x], a[x + 1]);
        } else {
            cout << solve(x) << '\n';
        }
    }
    return 0;
}
