#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int maxn = 2e5 + 1;

void solve() {
    int n, q; cin >> n >> q;

    vector<int> a(n);
    for (int i{}; i < n; i++) {
        cin >> a[i];
    }

    bool ch = true;
    vector<int> dp(n, -1);
    while (q--) {
        int t; cin >> t;

        if (t == 1) {
            int j; cin >> j;
            if (a[j] == a[j - 1]) continue;
            swap(a[j], a[j - 1]);
            ch = true;
        }
        else {
            int k; cin >> k;
            k--;

            if (ch) {
                // auto res = precalc(a);
                for (int i{}; i < n; i++) dp[i] = -1;
                int lst = 0;
                bool c = true;
                for (int i = 1; i < n; i++) {
                    if (!c) {
                        for (int j = 0; j < n; j++) {
                            if (dp[j] == -1) {
                                dp[j] = i;
                                break;
                            }
                        }
                        continue;
                    }
                    c = false;
                    for (int j = 0; j < n; j++) {
                        if (dp[j] == -1 && a[j] != lst) {
                            dp[j] = i;
                            lst = a[j];
                            c = true;
                            break;
                        }
                    }
                    
                    if (c) continue;
                    
                    for (int j = 0; j < n; j++) {
                        if (dp[j] == -1) {
                            dp[j] = i;
                            break;
                        }
                    }
                    
                }
            }
            ch = false;

            cout << dp[k] << '\n';

        }
    }

}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int it = 1;

    //cin >> it;

    while (it--) {
        solve();
    }
}