#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;

using ll=long long;
#define int ll

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int MOD = 998244353;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (auto &i : a) cin >> i;
    vector<int> ind(n);
    auto count = [&]()->void{
        int curind = 0;
        deque<int> buff;
        int last = -1;
        for (int i = 0; i < n; i++) {
            if (buff.size() > 0 && a[buff.front()] != last) {
                last = a[buff.front()];
                ind[buff.front()] = curind;
                curind++;
                buff.pop_front();
            }
            if (a[i] != last) {
                ind[i] = curind;
                curind++;
                last = a[i];
            } else {
                buff.push_back(i);
            }
        }
        while (buff.size() > 0) {
            last = a[buff.front()];
            ind[buff.front()] = curind;
            curind++;
            buff.pop_front();
        }
    };
    count();
    while (q--) {
        int t;
        cin >> t;
        if (t == 2) {
            int y;
            cin >> y;y--;
            cout << ind[y] + 1 << "\n";
        } else {
            int x;
            cin >> x;
            if (a[x - 1] == a[x]) continue;
            swap(a[x - 1], a[x]);
            count();
            // swap(ind[x - 1], ind[x]);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
