#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q; cin >> n >> q;
    vector<int> a(n);
    vector<bool> used(n, false);
    for (auto& x : a) cin >> x;
    while (q--) {
        used.clear();
        used.assign(n, false);
        int t; cin >> t;
        if (t == 2) {
            int y; cin >> y;
            int now = 0;
            int cnt = 1;
            used[0] = true;
            bool fl = true;
            while ((now + 1) != y && fl) {
                fl = false;
                for (int i = 1; i < n; i++) {
                    if (used[i]) continue;
                    if (a[i] != a[now]) {
                        fl = true;
                        used[i] = true;
                        cnt++;
                        now = i;
                        break;
                    }
                }
            }
            if (!fl) {
                for (int i = 1; i < y; i++) 
                    if (!used[i]) cnt++;
            }
            cout << cnt << "\n";
        } else {
            int x; cin >> x;
            swap(a[x], a[x - 1]);
        }
    }
}