#include <bits/stdc++.h>

using namespace std;
#define int long long

void bad() {
    int n;
    cin >> n;
    int q;
    cin >> q;
    vector <int> val(n);
    for (int i = 0; i < n; ++i) {
        cin >> val[i];
    }
    vector <int> vis(n);
    for (int j = 0; j < q; ++j) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            --x;
            swap(val[x], val[x + 1]);
        } else {
            fill(vis.begin(), vis.end(), 0);
            int num;
            cin >> num;
            --num;
            bool flag = false;
            int lc = - 1;
            for (int i = 0; i < n; ++i) {
                for (int f = 0; f < n; ++f) {
                    if (vis[f] == 0 && val[f] != lc) {
                        vis[f] = 1;
                        lc = val[f];
                        if (f == num) {
                            cout << i + 1 << '\n';
                            flag = true;
                            break;
                        } else {
                            break;
                        }
                    }
                }
                if (flag) {
                    break;
                }
            }
            if (!flag) {
                int c1 = 0, c2 = 0;
                for (int i = 0; i < n; ++i) {
                    if (!vis[i]) {
                        if (i <= num) {
                            ++c1;
                        }
                        ++c2;
                    }
                }
                cout << n - (c2 - c1) << '\n';
            }
        }
    }
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    bad();
}
