#include <bits/stdc++.h>

#define int long long

using namespace std;
using ll = long long;
using ld = long double;

const int inf = 1e9;
const int mod = 998244353;

void build(vector<int> &v, vector<int> &ans, int n) {
    set<int> s;
    vector<vector<int>> dp(n + 1);
    for (int i = 1; i <= n; i++) {
        dp[v[i]].push_back(i);
    }

    vector<int> pos(n + 1, inf);
    for (int i = 1; i <= n; i++) {
        if (!dp[i].empty()) {
            pos[i] = 0;
            s.insert(dp[i][0]);
        }
    }

    int cnt = 1;
    int now = 1;
    while (cnt <= n) {
        ans[now] = cnt++;
        s.erase(now);
        if (s.empty()) {
            break;
        }
        int elem = *s.begin();
        pos[v[now]]++;
        if (pos[v[now]] != dp[v[now]].size()) {
            s.insert(dp[v[now]][pos[v[now]]]);
        }

        now = elem;
    }

    for (int i = 1; i <= n; i++) {
        if (ans[i] == 0) {
            ans[i] = cnt++;
        }
    }
}

void go() {
    int n, q;
    cin >> n >> q;
    vector<int> v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }

    vector<int> ans(n + 1);
    build(v, ans, n);
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            cin >> i;
            swap(v[i], v[i + 1]);
            build(v, ans, n);
        } else {
            int x;
            cin >> x;
            cout << ans[x] << '\n';
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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