#include <type_traits>
#include <bits/stdc++.h>

using namespace std;


void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int cnt = 0;
    int last = -1;
    for (int i = 0; i < n; i++) {
        if (last != a[i]) {
            cnt++;
            last = a[i];
        }
    }
    vector<deque<int>> ind(cnt);
    vector<int> numb(n);
    vector<int> free(cnt);
    vector<int> used(n);
    int cur = 0;
    last = -1;
    for (int i = 0; i < n; i++) {
        numb[i] = cur;
        if (last != a[i]) {
            free[cur] = i;
            last = a[i];
        }
        if (i == n - 1 || a[i] == a[i + 1]) {
            continue;
        }
        int b = cur;
        for (int j = i + 1; j < n; j++) {
            if (a[j - 1] == a[j]) {
                continue;
            }
            ind[cur].push_back(++b);
        }
        cur++;
    }
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            int j;
            cin >> j;
            j--;
            swap(a[j], a[j + 1]);
        } else {
            used.assign(n, 0);
            int pos;
            cin >> pos;
            pos--;
            vector<int> lastind;
            last = -1;
            bool lastf = true;
            bool curfalg = false;
            while (lastind.empty() || pos != lastind.back()) {
                for (int j = 0; j < n; j++) {
                    if ((!used[j] && last != a[j]) || (!used[j] && last == a[j] && !lastf)) {
                        used[j] = 1;
                        lastind.push_back(j);
                        last = a[j];
                        curfalg = true;
                        break;
                    }
                }
                lastf = curfalg;
                curfalg = false;
            }
            cout << (int) lastind.size() << '\n';
        }
    }
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}