#include <bits/stdc++.h>

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

void solve() {
    int n, q;
    cin >> n >> q;
    vector <ll> a(n);
    for (auto &e : a) {
        cin >> e;
    }
    auto calc = [&]() {
        set <pair <int, int>> st;
        int pr = 0;
        for (int i = 1; i < n; i++) {
            if (a[i] != a[i - 1]) {
                st.insert({pr, i - 1});
                pr = i;
            }
        }
        st.insert({pr, n - 1});
        vector <int> ans(n, -1);
        ll c = -1;
        for (int i = 0; i < n; i++) {
            auto [l, r] = *st.begin();
            st.erase(st.begin());
            if (ans[l] != -1) {
                if (l < r) {
                    st.insert({l + 1, r});
                }
                i--;
                continue;
            }
            if (a[l] == c && st.size()) {
                auto [l1, r1] = *st.begin();
                st.erase(st.begin());
                ans[l1] = i;
                if (l1 < r1) {
                    st.insert({l1 + 1, r1});
                } else if (st.size() && a[l] == a[st.begin()->first]){
                    r = st.begin()->second;
                    st.erase(st.begin());
                }
                c = a[l1];
            } else {
                ans[l] = i;
                c = a[l];
                l++;
            }
            if (l <= r) {
                st.insert({l, r});
            }
        }
        return ans;
    };
    vector <int> ans = calc();
    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            if (a[x] != a[x - 1]) {
                swap(a[x], a[x - 1]);
                swap(ans[x], ans[x - 1]);
            }
        } else {
            cout << ans[x - 1] + 1 << '\n';
        }
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

// Halal code
