
#include <bits/stdc++.h>

using namespace std;
#define ll long long
const ll INF = 1e15;
const ll mod = 998244353;

ll n;

vector<ll> rask(vector<ll> &v) {
    vector<ll> res;
    res.push_back(0);
    vector<ll> rev(n);
    rev[0] = 0;

    queue<ll> q;
    ll id = 1;
    while (id < n) {
        ll x = id;
        while (x < n && v[x] == v[res.back()]) {
            q.push(x);
            x++;
        }
        if (x < n)
            res.push_back(x);
        if (!q.empty()) {
            res.push_back(q.front());
            q.pop();
        }
        id = x + 1;
    }
    for (int i = 0; i < n; ++i) {
        rev[res[i]] = i;
    }
    return rev;
}

ll q;

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n >> q;
    vector<ll> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        v[i]--;
    }
    vector<ll> nw = rask(v);
    while (q--) {
        ll t;
        cin >> t;
        if (t == 1) {
            ll x;
            cin >> x;
            x--;
            swap(v[x], v[x + 1]);
            nw = rask(v);
        } else {
            ll y;
            cin >> y;
            y--;
            cout << nw[y] + 1 << '\n';
        }
    }
}