#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
using ll = long long;
using namespace std;
// #pragma GCC optimize("O3, unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
//  using ordered_set = tree<int, null_type, less<int>, rb_tree_tag,
//  tree_order_statistics_node_update>;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (auto& x : a) cin >> x;
    vector<int> ans(n, 0);
    bool f = 0;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        } else {
            if (!f) {
                vector<int> used(n, 0);
                int cur = -1;
                bool f = 0;
                int it = 1;
                for (int i = 0; i < n; ++i) {
                    bool ff = 0;
                    for (int j = 0; j < n; ++j) {
                        if (used[j])
                            continue;
                        if (f || cur != a[j]) {
                            used[j] = 1;
                            cur = a[j];
                            ans[j] = it++;
                            ff = 1;
                            break;
                        }
                    }
                    if (!ff) {
                        for (int j = 0; j < n; ++j) {
                            if (used[j])
                                continue;
                            used[j] = 1;
                            cur = a[j];
                            ans[j] = it++;
                        }
                        break;
                    }
                }
            }
            int y;
            cin >> y;
            y--;
            cout << ans[y] << '\n';
        }
    }
    return 0;
}
