#include<bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

ll n, q;
vector<ll> a;
vector<pair<ll, ll>> b;

void input() {
    cin >> n >> q;
    a.resize(n);
    b.resize(q);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = 0; i < q; i++) {
        cin >> b[i].first >> b[i].second;
    }
}

void solve() {
    vector<ll> num;
    bool fl = true;
    for (ll i = 0; i < q; i++) {
        if (b[i].first == 1) {
            swap(a[b[i].second - 1], a[b[i].second]);
            fl = true;
        } else {
            if (fl) {
                vector<ll> cop = a;
                num.assign(n, 0);
                ll cnt = 1, l = 0, r = 0, lst = -1;
                while (l < n) {
                    if (cop[l] == lst) {
                        while (r < n && cop[r] == lst) {
                            r++;
                        }
                        if (r == n) {
                            for (ll i = l; i < n; i++) {
                                if (cop[i] != -1) {
                                    num[i] = cnt++;
                                }
                            }
                            break;
                        } else {
                            cop[r] = -1;
                            num[r] = cnt++;
                            lst = cop[l];
                            cop[l] = -1;
                            num[l] = cnt++;
                            l++;
                            r++;
                        }
                    } else {
                        lst = cop[l];
                        cop[l] = -1;
                        num[l] = cnt++;
                        l++;
                    }
                    while (l < n && cop[l] == -1) {
                        l++;
                    }
                    r = max(r, l);
                }
            }
            cout << num[b[i].second - 1] << "\n";
            fl = false;
        }
    }
}

void output() {

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    input();
    solve();
    output();
    return 0;
}
