#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;

inline vector<int> precalc(vector<int> &a) {
    deque<int> st;
    vector<int> res(a.size(), -1);
    for (int i{}; i < a.size(); i++) {
        if (st.size() && a[st[0]] != a[i]) {
            if (st[0] == i - 1) {
                st[0] = i;
                continue;
            }
            res[st[0]] = i;
            st.pop_front();
        }
        else {
            st.push_back(i);
        }
    }

    return res;
}

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

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

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

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

            if (ch) {
                tm++;
                auto res = precalc(a);
                int cnt = 1;
                for (int i{}; i < n; i++) {
                    if (dp[i].second != tm) dp[i] = {-1, tm};
                    if (dp[i].first == -1) {
                        dp[i].first = cnt++;
                        if (res[i] != -1 && res[i] != i + 1) dp[res[i]] = {cnt++, tm};
                    }
                }

                cerr << "||||||||||||||\n";
                for (auto i : dp) {
                    cerr << i.first << " ";
                }
                cerr << "\n";
                for (auto i : res) {
                    cerr << i << " ";
                }
                cerr << '\n';
            }
            ch = false;



            cout << dp[j].first << '\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();
    }
}