#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;

const ll mod = 998244353;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (auto& i : a)
        cin >> i;
    vector<int> cnt(n, 0), nxt(n, 0);
    bitset<100100> used = 0;
    int type, i, now, pr;
    bool f = 0;
    while (q--) {
        cin >> type >> i;
        i--;
        if (type == 1) {
            swap(a[i], a[i + 1]);
            f = 0;
        } else {
            if (!f) {
                f = 1;
                used = 0;
                cnt[0] = 1;
                now = 2, pr = a[0];
                nxt[n - 1] = n;
                for (int i = n - 2; i + 1; --i) {
                    if (a[i + 1] != a[i])
                        nxt[i] = i + 1;
                    else
                        nxt[i] = nxt[i + 1];
                }
                for (int i = 1; i < n; ++i) if (!used[i]) {
                    if (a[i] == pr) {
                        nxt[i] = nxt[i - 1];
                        while (used[nxt[i]])
                            nxt[i]++;
                        if (nxt[i] != n) {
                            used[nxt[i]] = 1;
                            cnt[nxt[i]] = now++;
                        }
                    }
                    cnt[i] = now++;
                    pr = a[i];
                }
                f = 1;
            }
            cout << cnt[i] << '\n';
        }
    }
}

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