#include <bits/stdc++.h>

using namespace std;

vector<int> solve(vector<int> a) {
    deque<pair<int, int>> q;
    int n = a.size();
    for (int i = 0; i < n; i++) {
        q.push_back({i, a[i]});
    }
    vector<int> res;
    int prv = -1;
    deque<pair<int, int>> q2;
    for (int i = 0; i < n; i++) {
        pair<int, int> cur = {-1, -1};
        if (q2.size()) {
            cur = q2.front();
            q2.pop_front();
        } else {
            while (q.size() && q.front().second == prv) {
                q2.push_back(q.front());
                q.pop_front();
            }
            if (q.empty()) break;
            cur = q.front();
            q.pop_front();
        }
        res.push_back(cur.first);
        prv = cur.second;
    }
    while (q2.size()) {
        res.push_back(q2.front().first);
        q2.pop_front();
    }
    return res;
}

signed main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    // for (int i : solve(a)) cout << i << " ";
    // cout << "\n";
    // return 0;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        } else {
            int y;
            cin >> y;
            y--;
            auto t = solve(a);
            for (int i = 0; i < n; i++) {
                if (t[i] == y) {
                    cout << i + 1 << "\n";
                }
            }
        }
    }
}