#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using i128 = __int128_t;

const ll inf = 1e18 + 1e16;
const ll inf_t = 1e9 + 7;
const ll mod = 998244353;

#define int ll

void solve() {
    int n, q;
    cin >> n >> q;

    vector <int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) --a[i];
    
    int cnt[n];
    int it[n];
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            cin >> i;
            swap(a[i - 1], a[i]);
            continue;
        }

        int ind;
        cin >> ind;
        --ind;

        vector <vector <int>> cl(n);
        for (int i = 0; i < n; ++i) {
            cl[a[i]].push_back(i);
        }

        set <pair <int, int>> s;
        for (int i = 0; i < n; ++i) {
            if (cl[i].size() != 0) {
                s.insert(make_pair(cl[i][0], i));
            }
        }

        int pos = 0;
        fill(it, it + n, 0);
        int prev = -1;
        while (!s.empty()) {
            int i = s.begin()->second;
            if (s.size() == 1 || i != prev) {
                s.erase(s.begin());
            } else {
                auto itr = s.begin();
                itr = next(itr);
                i = itr->second;
                s.erase(itr);
            }

            cnt[cl[i][it[i]++]] = pos++;

            if (it[i] != cl[i].size()) {
                s.insert(make_pair(cl[i][it[i]], i));
            }

            prev = i;
        }

        cout << cnt[ind] + 1 << "\n";
    }
}

signed main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
