#pragma GCC optimize ("o2")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) a.begin(), a.end()
const int MAXN = 1e6 + 1, MOD = 998244353;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (auto &i : a) cin >> i;
    for (int i = 0; i < n; ++i) {
        a[i]--;
    }
    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            swap(a[x - 1], a[x]);
        } else {
            x--;
            vector<vector<int>> color(n);
            set<pair<int, int>> s;
            for (int i = 0; i < n; ++i) {
                color[a[i]].push_back(i);
            }
            for (int i = 0; i < n; ++i) {
                reverse(all(color[i]));
            }
            for (int i = 0; i < n; ++i) {
                if (!color[i].empty()) {
                    s.emplace(color[i].back(), i);
                }
            }
            int last = -1;
            for (int i = 1; i <= n; ++i) {
                auto [p, y] = (*s.begin());
                s.erase(s.begin());
                if (y != last || s.empty()) {
                    last = y;
                    if (p == x) {
                        cout << i << '\n';
                        break;
                    }
                    color[y].pop_back();
                    if (!color[y].empty()) {
                        s.emplace(color[y].back(), y);
                    }
                } else {
                    auto [p1, y1] = (*s.begin());
                    last = y1;
                    s.erase(s.begin());
                    s.emplace(p, y);
                    if (p1 == x) {
                        cout << i << '\n';
                        break;
                    }
                    color[y1].pop_back();
                    if (!color[y1].empty()) {
                        s.emplace(color[y1].back(), y1);
                    }
                }
            }
            color.clear();
            s.clear();
        }
    }
}

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