#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

// #define int long long
#pragma GCC optimize("O3, unroll-loops")
#pragma GCC target("avx2")

// using namespace __gnu_pbds;
using ll = long long;
using namespace std;

// template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<int> f(int n, vector<int> &a) {
    int cnt = 0, ind = 0;
    vector<int> cur, ans(n, -1);
    for (int i = 0; i < n; i++) {
        if (ans[i] != -1) {
            continue;
        }
        if (!cur.empty() && cur.back() == a[i]) {
            ind = max(ind, i);
            while (ind != n && a[ind] == cur.back()) {
                ind++;
            }
            if (ind != n) {
                ans[ind] = cur.size();
                cur.push_back(a[ind]);
                ind++;
            }
        }
        ans[i] = cur.size();
        cur.push_back(a[i]);
    }
    return ans;
}

void solve() {
    int n, q, mn;
    cin >> n >> q;
    mn = n;
    vector<int> ans, a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ans = f(n, a);
    while (q--) {
        int t, ind;
        cin >> t >> ind;
        ind--;
        if (t == 1 && a[ind] != a[ind + 1]) {
            swap(ans[ind], ans[ind + 1]);
        } else if (t == 2) {
            cout << ans[ind] + 1 << "\n";
        }
    }
}

signed main() {
    int t = 1;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    // cin >> t;
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    // cin >> t;
    while (t--) {
        solve();
    }
}