#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, pr;
int tmr = 0;

int get(int ind) {
    tmr++;
    vector<list<int>> colors(n);
    for (int i = 0; i < n; i++)
        colors[clr[i]].push_back(i);
    set<pair<int, int>> st;
    for (int i = 0; i < n; i++)
        if (colors[i].size())
            st.insert({colors[i].front(), i});
    int res = 1, lst = -1;
    while (st.size()) {
        auto [i, clr] = *st.begin();
        st.erase(st.begin());
        int inow = i, clrnow = clr;
        if (clr == lst && st.size()) {
            auto [i1, clr1] = *st.begin();
            st.erase(st.begin());
            inow = i1;
            clrnow = clr1;
            colors[clr1].pop_front();
            if(colors[clr1].size())
                st.insert({colors[clr1].front(), clr1});
            st.insert({i, clr});
        } else {
            colors[clr].pop_front();
            if(colors[clr].size())
                st.insert({colors[clr].front(), clr});
        }
        if (inow == ind)
            return res;
        lst = clrnow;
        res++;
    }
}

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);
    pr.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;
}
