#include<bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) (x).begin(), (x).end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const char nl = '\n';

template<typename T>
istream &operator>> (istream& in, vector<T>& a) {
    for (auto &el : a) in >> el;
    return in;
}

template<typename T>
ostream& operator<< (ostream& out, vector<T> &a) {
    for (auto &el : a) out << el << ' ';
    return out;
}

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

vector<int> get(vector<int>& a) {
    int cnt = 0;
    int n = a.size();
    deque<int> dq, c, ind;
    cnt = 1;
    int sum = 0;
    ind.push_back(0);
    for (int i = 1; i <= n; i++) {
        if (i == n || a[i] != a[i - 1]) {
            dq.push_back(a[i - 1]);
            c.push_back(cnt);
            sum += cnt;
            ind.push_back(sum);
            cnt = 0;
        }
        cnt++;
    }
    ind.pop_back();

    int last = 0;
    vector<int> ans(n);
    int timer = 1;
    while (!dq.empty()) {
        if (dq.size() > 1 && dq[0] == dq[1]) {
            int new_cnt = c[0] + c[1];
            int add = dq[0];
            dq.pop_front();
            dq.pop_front();
            c.pop_front();
            c.pop_front();
            dq.push_front(add);
            c.push_front(add);
        }
        if (dq.size() == 1) {
            while (c[0]--) {
                while (ans[ind[0]] != 0)
                    ind[0]++;
                ans[ind[0]] = timer++;
            }
            break;
        }

        cout << last << nl;
        cout << "dq: ";
        for (auto el : dq)
            cout << el << ' ';
        cout << nl;
        cout << "c: ";
        for (auto el : c)
            cout << el << ' ';
        cout << nl;
        cout << "ind: ";
        for (auto el : ind)
            cout << el << ' ';
        cout << nl;
        cout << "ans: ";
        cout << ans << nl << nl;
        if (dq[0] != last) {
            last = dq[1];
            if (c[0] > c[1]) {
                int new_cnt = c[0] - c[1];
                int add = dq[0];

                for (int i = 0; i < c[1]; i++) {
                    ans[ind[0]] = timer++;
                    ans[ind[1]] = timer++;
                    int need = a[ind[0]];
                    while (ans[ind[0]] != 0)
                        ind[0]++;

                    need = a[ind[1]];
                    while (ans[ind[1]] != 0)
                        ind[1]++;
                }
                int new_ind = ind[0];
                ind.pop_front();
                ind.pop_front();
                ind.push_front(new_ind);

                dq.pop_front();
                dq.pop_front();
                c.pop_front();
                c.pop_front();
                dq.push_front(add);
                c.push_front(new_cnt);
            } else if (c[0] == c[1]) {
                for (int i = 0; i < c[1]; i++) {
                    ans[ind[0]] = timer++;
                    ans[ind[1]] = timer++;
                    int need = a[ind[0]];
                    ind[0]++;
                    while (ans[ind[0]] != 0)
                        ind[0]++;

                    need = a[ind[1]];
                    ind[1]++;
                    while (ans[ind[1]] != 0)
                        ind[1]++;
                }
                dq.pop_front();
                dq.pop_front();
                c.pop_front();
                c.pop_front();
                ind.pop_front();
                ind.pop_front();
            } else {
                int new_cnt = c[1] - c[0];
                int add = dq[1];

                for (int i = 0; i < c[0]; i++) {
                    ans[ind[0]] = timer++;
                    ans[ind[1]] = timer++;
                    int need = a[ind[0]];
                    ind[0]++;
                    while (ans[ind[0]] != 0)
                        ind[0]++;

                    need = a[ind[1]];
                    ind[1]++;
                    while (ans[ind[1]] != 0)
                        ind[1]++;
                }
                int new_ind = ind[1];
                ind.pop_front();
                ind.pop_front();
                ind.push_front(new_ind);
                dq.pop_front();
                dq.pop_front();
                c.pop_front();
                c.pop_front();
                dq.push_front(add);
                c.push_front(new_cnt);
            }
        } else {
            last = dq[0];
            if (c[0] > c[1]) {
                int new_cnt = c[0] - c[1];
                int add = dq[0];
                for (int i = 0; i < c[1]; i++) {
                    ans[ind[0]] = timer + 1;
                    ans[ind[1]] = timer;
                    timer += 2;
                    int need = a[ind[0]];
                    ind[0]++;
                    while (ans[ind[0]] != 0)
                        ind[0]++;

                    need = a[ind[1]];
                    ind[1]++;
                    while (ans[ind[1]] != 0)
                        ind[1]++;
                }

                int new_ind = ind[0];
                ind.pop_front();
                ind.pop_front();
                ind.push_front(new_ind);
                dq.pop_front();
                dq.pop_front();
                c.pop_front();
                c.pop_front();
                dq.push_front(add);
                c.push_front(new_cnt);
            } else if (c[0] < c[1]) {
                int new_cnt = c[1] - c[0];
                int add = dq[1];
                for (int i = 0; i < c[0]; i++) {
                    ans[ind[0]] = timer + 1;
                    ans[ind[1]] = timer;
                    timer += 2;
                    int need = a[ind[0]];
                    ind[0]++;
                    while (ans[ind[0]] != 0)
                        ind[0]++;

                    need = a[ind[1]];
                    ind[1]++;
                    while (ans[ind[1]] != 0)
                        ind[1]++;
                }
                ind.pop_front();
                ind.pop_front();
                dq.pop_front();
                dq.pop_front();
                c.pop_front();
                c.pop_front();
                dq.push_front(add);
                c.push_front(new_cnt);
            } else {
                for (int i = 0; i < c[1]; i++) {
                    ans[ind[0]] = timer + 1;
                    ans[ind[1]] = timer;
                    timer += 2;
                    int need = a[ind[0]];
                    ind[0]++;
                    while (ans[ind[0]] != 0)
                        ind[0]++;

                    need = a[ind[1]];
                    ind[1]++;
                    while (ans[ind[1]] != 0)
                        ind[1]++;
                }

                int new_ind = ind[0];
                ind.pop_front();
                ind.pop_front();
                ind.push_front(new_ind);
                dq.pop_front();
                dq.pop_front();
                c.pop_front();
                c.pop_front();
            }
        }
    }
    return ans;
}


signed main() {
    fast();
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    cin >> a;
    while (q--) {
        int op;
        cin >> op;
        if (op == 1) {
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        } else {
            vector<pii> p(n);
            for (int i = 0; i < n; i++) {
                p[i] = {a[i], i + 1};
            }
            int last = 0;
            vector<int> ans(n + 1);
            vector<int> q;
            while (!p.empty()) {
                int ind = -1;
                for (auto el : p) {
                   // cout << el.first << ' ';
                }
                //cout << nl;
                for (int i = 0; i < p.size(); i++) {
                    if (last != p[i].first) {
                        ans[p[i].second] = q.size() + 1;
                        //cout << p[i].first << ' ' << p[i].second << ' ' << q.size() + 1 << nl;
                        ind = i;
                        q.push_back(p[i].first);
                        last = p[i].first;
                        break;
                    }
                }

                if (ind == -1) {
                    for (int i = 0; i < p.size(); i++) {
                        ans[p[i].second] = q.size() + 1;
                        q.push_back(p[i].first);
                    }
                    p.clear();
                } else {
                    p.erase(p.begin() + ind);
                }
            }

            int x;
            cin >> x;
            cout << ans[x] << nl;
        }
    }
}
