#pragma GCC optimize("03,Ofast,unroll-loops")

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (auto & el : a) cin >> el;
    set<pair<ll, ll>> s;
    for (int i = 0; i < n; ++i) {
        s.insert({i, a[i]});
    }

    vector<ll> used(n);
    vector<ll> has_stayed(n);
    bool is_upd = 1;
    for (int op = 0; op < q; ++op) {
        ll t;
        cin >> t;
        if (t == 2) {
            ll k;
            cin >> k;
            k--;
            if (!is_upd) {
                cout << used[k] << '\n';
                continue;
            }
            used.assign(n, 0);
            used[0] = 1;
            ll cur = 0;
            deque<ll> last;

            ll cnt = 1;
            for (int i = 1; i < n; ++i) {
                if (!last.empty() && a[last.front()] != a[cur]) {
                    cnt++;
                    used[last.front()] = cnt;
                    cur = last.front();
                    last.pop_front();
                }
                if (a[i] == a[cur]) {
                    last.push_back(i);
                    has_stayed[i] = 1;
                } else {
                    cnt++;
                    used[i] = cnt;
                    cur = i;
                }
            }
            while (!last.empty()) {
                used[last.front()] = ++cnt;
                last.pop_front();
            }
            is_upd = 0;
            cout << used[k] << '\n';
        } else {
            ll x;
            cin >> x;
            x--;
            is_upd = 1;
            if (has_stayed[x] || has_stayed[x + 1]) {
                is_upd = 0;
            }
            swap(a[x], a[x + 1]);
        }
    }
}