#include <bits/stdc++.h>
#pragma optimize("Ofast")
#pragma optimize("O3")

using namespace std;

using ll = long long;

const int INF = 1e9 + 7, mod = 998244353;

#ifdef LOCAL
const int MAXN = 1e2;
#else
const int MAXN = 1e6;
#endif

int n, q;
vector<int> clr, p;

vector<int> mxr, used;
int tmr = 0;

int get(int ind) {
    tmr++;
    for (int i = n - 1; i >= 0; i--) {
        mxr[i] = i;
        if (i + 1 < n && clr[i] == clr[i + 1])
            mxr[i] = mxr[i + 1];
    }
    int lst = -1, cnt = 1;
    for (int l = 0; l < n;) {
        while (used[l] == tmr && l < n)
            l++;
        int i = l;
        if (clr[i] == lst && mxr[i] + 1 < n) {
            i = mxr[i];
            i++;
        }
        if(i == ind) return cnt;
        used[i] = tmr;
        lst = clr[i];
        cnt++;
    }
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> q;
    clr.resize(n);
    mxr.resize(n);
    used.resize(n);
    for (int &i : clr) {
        cin >> i;
        i--;
    }
    while (q--) {
        int a, b;
        cin >> a >> b;
        b--;
        if (a == 1) {
            swap(clr[b], clr[b + 1]);
        } else {
            cout << get(b) << '\n';
        }
    }
    return 0;
}
