#include "bits/stdc++.h"

#pragma GCC optimize("03,unroll-loops")
#pragma GCC target("avx2")

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

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

void solve() {
    int n, tt;
    cin >> n >> tt;
    vector<int> a(n);
    for (auto &h : a) {
        cin >> h;
        --h;
    }
    vector<int> mp(n);
    const int N = 5000;
    bitset<N> use;
    for (int i = 1; i < n; ++i) use[i] = 1;
    use[0] = 0;
    mp[0] = 1;
    int ls = 2, now = 0;
    while (ls <= n) {
        int fl = 1;
        for (int i = use._Find_first(); i < n; i = use._Find_next(i)) {
            if (a[i] != a[now]) {
                use[i] = 0;
                fl = 0;
                mp[i] = ls++;
                now = i;
                break;
            }
        }
        if (fl) {
            for (int i = use._Find_first(); i < n; i = use._Find_next(i)) {
                use[i] = 0;
                mp[i] = ls++;
                now = i;
                break;
            }
        }
    }
    while (tt--) {
        int tp;
        cin >> tp;
        if (tp == 1) {
            int x;
            cin >> x;
            --x;
            swap(a[x], a[x + 1]);
            ls = 2, now = 0;
            for (int i = 1; i < n; ++i) use[i] = 1;
            use[0] = 0;
            while (ls <= n) {
                int fl = 1;
                for (int i = use._Find_first(); i < n; i = use._Find_next(i)) {
                    if (a[i] != a[now]) {
                        use[i] = 0;
                        fl = 0;
                        mp[i] = ls++;
                        now = i;
                        break;
                    }
                }
                if (fl) {
                    for (int i = use._Find_first(); i < n; i = use._Find_next(i)) {
                        use[i] = 0;
                        mp[i] = ls++;
                        now = i;
                        break;
                    }
                }
            }
        } else {
            int y;
            cin >> y;
            --y;
            cout << mp[y] << '\n';
        }
    }
}

/*
10 10
3 1 1 2 2 1 1 2 2 2
2 2
2 3
2 4
2 10
1 1
2 2
2 3
2 4
2 5
2 10

*/

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
    // cin >> _;
    while (_--) {
        solve();
        cout << '\n';
    }
}
