#include <iostream>
#include <vector>
#include <set>
#include <algorithm>



using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ull = unsigned long long;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    vector<set<int>> p(n);
    set<pii> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int prev = -1;
    vector<int> res(n);
    bool fl = true;
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x; cin >> x; x--;
            swap(a[x], a[x + 1]);
            fl = true;
        } else {
            int y; cin >> y; y--;
            if (y == 0) {
                cout << 1 << "\n";
                continue;
            }
            if (fl) {
                p.assign(n, set<int> ());
                s.clear();
                for (int i = 0; i < n; i++) {
                    p[a[i]].insert(i);
                    if ((int) p[a[i]].size() == 1) {
                        s.insert({i, a[i]});
                    }
                }
                res.assign(n, 0);
                prev = -1;
                for (int i = 0; i < n; i++) {
                    if (s.empty()) break;
                    auto it = s.begin();
                    auto [ind, cl] = *it;
                    if (cl == prev) {
                        if ((int) s.size() > 1) {
                            it = next(it);
                            ind = (*it).first;
                            cl = (*it).second;
                        }
                    }
                    res[ind] = i;
                    s.erase(it);
                    if (p[cl].empty()) break;
                    p[cl].erase(p[cl].find(ind));
                    if (!p[cl].empty())
                        s.insert({*(p[cl].begin()), cl});
                    prev = cl;
                }
                fl = false;
            }
            cout << res[y] + 1 << "\n";
        }
    }

}
