#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 cin(x) for (auto &i : (x)) cin >> i;
#define cout(x) for (auto &i : (x)) cout << i << " "; cout << "\n"
#define fori(x) for (int i = 0; i<(x); i++)
#define forj(x) for (int j = 0; j<(x); j++)
#define fork(x) for (int k = 0; k<(x); k++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    cin(a);
    fork(q) {
        int t;
        cin >> t;
        if (t == 1) {
            int j;
            cin >> j;
            j--;
            swap(a[j], a[j + 1]);
        } else {
            int j;
            cin >> j;
            j--;
            vector<int> ans{0};
            vector<int> use(n);
            use[0] = 1;
            int r = 1;
            for (int i = 1; i < n; i++) {
                if (use[i]) continue;
                r = max(r, i);
                while (r < n && a[r] == a[i]) r++;
                if (r == n) {
                    ans.push_back(i);
                } else {
                    if (a[i] == a[ans.back()]) {
                        ans.push_back(r);
                        use[r] = 1;
                        ans.push_back(i);
                    } else {
                        ans.push_back(i);
                    }
                }
            }
            // cout(a);
            // cout(ans);
            // cout << endl;
            cout << find(all(ans), j) - ans.begin() + 1 << "\n";
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}
