#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);
    int type, i, now, pr, npr, idx;
    bool f = 0;
    while (q--) {
        cin >> type >> i;
        i--;
        if (type == 1) {
            swap(a[i], a[i + 1]);
            if (a[i] != a[i + 1])
                f = 0;
        } else {
            if (!f) {
                f = 1;
                idx = 0, now = 2, pr = a[0], npr = nxt[0];
                nxt[n - 1] = n;
                cnt[n - 1] = 0;
                for (int i = n - 2; i + 1; --i) {
                    if (a[i + 1] != a[i])
                        nxt[i] = i + 1;
                    else
                        nxt[i] = nxt[i + 1];
                    cnt[i] = 0;
                }
//                for (int i = 0; i < n; ++i)
//                    cout << nxt[i] << ' ';
//                cout << '\n';
                cnt[0] = 1;
                for (int i = 1; i < n; ++i) if (!cnt[i]) {
                    if (a[i] == pr) {
                        idx = max(nxt[i], npr);
                        while (idx < n && (cnt[idx] || a[idx] == a[i]))
                            idx++;
                        if (idx != n)
                            cnt[idx] = now++;
                        //cout << i << ' ' << idx << ' ' << now - 1 << '\n';
                    }
                    cnt[i] = now++;
                    pr = a[i];
                    npr = (idx >= n ? 0 : idx);
                }
            }
            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;
}
