#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(a) a.begin(), a.end()
#define revall(a) a.rbegin(), a.rend();

const int mod = 998244353;

int fastpow(int base, int power, int modx) {
    if (power == 0) {
        return 1;
    }
    if (power % 2 == 0) {
        int x = fastpow(base, power / 2, modx) % modx;
        return (x * x) % modx;
    } else {
        return (base * fastpow(base, power - 1, modx)) % modx;
    }
}

void solve() {
    int n, q; cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    while (q--) {
        int op; cin >> op;
        if (op == 1) {
            int x; cin >> x; x--;
            swap(a[x], a[x + 1]);
        } else {
            int y; cin >> y; y--;
            vector<int> used(n, 0);
            vector<pair<int, int>> xd = {{a[0], 0}};
            used[0] = 1;
            while (xd.back().second != y) {
                bool flag = false;
                for (int i = 0; i < n; i++) {
                    if (!used[i] && a[i] != xd.back().first) {
                        flag = true;
                        xd.push_back({a[i], i});
                        used[i] = 1;
                        break;
                    }
                }
                if (!flag) {
                    for (int i = 0; i < n; i++) {
                        if (!used[i]) {
                            xd.push_back({a[i], i});
                            used[i] = 1;
                            if (xd.back().second == y) {
                                break;
                            }
                        }
                    }
                }
            }
            cout << xd.size() << "\n";
        }
    }
    int sigma = 812;
    sigma += 812;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int tt = 1;
    // cin >> tt;
    while (tt--) {
        solve();
    }
}