#include <bits/stdc++.h>

using namespace std;

// #define int ll
#define endl '\n'

typedef long long ll;

void solve() {
#ifdef LOCAL
    cout << "___NEW___" << endl;
#endif
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int _ = 0; _ < q; _++) {
        int mode;
        cin >> mode;
        if (mode == 1) {
            int x;
            cin >> x;
            --x;
            swap(a[x], a[x + 1]);
        } else {
            int y;
            cin >> y;
            --y;
            if (y == 0) {
                cout << 1 << endl;
                continue;
            }
            int cur = 0;

            vector<bool> used(n);
            used[0] = true;
            for (int cnt = 1; cnt < n; cnt++) {
                int i = 0;
                int j = -1;
                for (; i < n && (a[i] == a[cur] || used[i]); i++) {
                    if (!used[i] && j == -1)
                        j = i;
                }
                if (i == n)
                    i = j;
                cur = i;
                used[cur] = true;
                if (cur == y) {
                    cout << cnt + 1 << endl;
                }
            }
        }
    }
}

signed main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int qwe = 1;
#ifdef LOCAL
    cin >> qwe;
#endif
    for (int _ = 0; _ < qwe; _++) {
        solve();
    }
    return 0;
}