#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using ld = long double;
template<typename T> 
using orset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod = 998244353;

ll stmod(ll a, ll st) {
    if (st == 0) return 1;
    if (st & 1) return stmod(a, st - 1) * a % mod;
    ll hf = stmod(a, st / 2);
    return hf * hf % mod;
}

int main () {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    vector<int> col1(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        // col1[i] += (a[i] == 1);
    }
    // int z = n - col1[n - 1];
    // for (int i = 0; i < q; i++) {
    //     int tp;
    //     cin >> tp;
    //     if (tp == 1) {
    //         int x;
    //         cin >> x;
    //         x--;
    //         col1[x] += (a[x + 1] == 1) - (a[x] == 1);
    //         swap(a[x], a[x + 1]);
    //     } else {
    //         int y;
    //         cin >> y;
    //         y--;
    //         if (a[y] == 1)
    //     }
    // }
    vector<int> num(n);
    for (int i = 0; i < q; i++) {
        int tp;
        cin >> tp;
        if (tp == 1) {
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        }
        if (tp == 1 || !i) {
            queue<int> mx;
            int tx = 1, pr = -1;
            for (int j = 0; j < n; j++) {
                if (pr == a[j]) mx.push(j);
                else {
                    num[j] = tx++;
                    if (!mx.empty()) {
                        num[mx.front()] = tx++;
                        mx.pop();
                    }
                    pr = a[j];
                }
            }
            while (!mx.empty()) {
                num[mx.front()] = tx++;
                mx.pop();
            }
        }
        if (tp == 2) {
            int y;
            cin >> y;
            y--;
            cout << num[y] << "\n";
        }
    }
}
