#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    while (q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int id;
            cin >> id;
            swap(arr[id - 1], arr[id]);
        } else {
            vector<int> ind;
            queue<int> que;
            for (int i = 0; i < n; i++) {
                if (ind.empty() || arr[ind.back()] != arr[i]) {
                    ind.push_back(i);
                } else {
                    que.push(i);
                }
                while (!que.empty() && (ind.empty() || arr[que.front()] != arr[ind.back()])) {
                    ind.push_back(que.front());
                    que.pop();
                }
            }
            while (!que.empty()) {
                ind.push_back(que.front());
                que.pop();
            }
            int id;
            cin >> id;
            id--;
            int res = 0;
            while (ind[res] != id) {
                res++;
            }
            cout << res + 1 << '\n';
        }
    }
    return 0;
}