#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int& x : a) cin >> x;
    while (q-- > 0) {
        int tp;
        cin >> tp;
        if (tp == 1) {
            int x;
            cin >> x;
            --x;
            swap(a[x], a[x + 1]);
        } else {
            int y;
            cin >> y;
            --y;

            vector<int> used(n);
            vector<int> pos(n);
            int cnt=0;
            int j = 0, lst = -1;
            for (int i = 0; i < n; ++i) {
                if (used[i]) continue;
                j = max(i, j);
                if (lst == a[i]) {
                    while (j < n && a[j] == a[i]) ++j;
                    if (j < n) {
                        used[j] = 1;
                        pos[j] = cnt;
                        ++cnt;
                        lst = a[j];
                        ++j;
                    }
                }
                used[i] = 1;
                pos[i] = cnt;
                ++cnt;
                lst = a[i];
            }
            cout << pos[y] + 1 << '\n';
        }

    }
    return 0;
}