#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int A = 1e4 + 5;
const int MOD = 998244353;


ll n, q, tp, i, x, a[A], l, cnt = 1, h, fl[A];
set<int> st;

void Try(deque<pll> &k) {
    while ((int)(k.size()) >= 2) {
//        cout << 1 << endl;
        auto to = k[0];
        auto to1 = k[1];
        k.pop_front();
        k.pop_front();
        if (a[to.fi] == a[to1.se]) {
            k.push_front({to.fi, to1.se});
        } else {
            k.push_front(to1);
            k.push_front(to);
            return;
        }
    }
}

void f(int x) {
    int i, j, l = 1, ls, fl, cnt = 1;
    set<pll>st;
    for (i = 1; i <= n; i++) {
        if (a[i] != a[i + 1]) {
            st.insert({l, i});
            l = i + 1;
        }
    }
    for (i = 1; i <= n; i++) {
        set<pll>st1 = st;
        fl = 1;
        for (auto to : st1) {
            if (a[to.fi] != ls) {
                if (to.fi == x) {
                    cout << cnt << "\n";
                    return;
                }
                ls = a[to.fi];
                st.erase({to.fi, to.se});
                if (to.fi + 1 <= to.se) {
                    st.insert({to.fi + 1, to.se});
                }
                fl = 0;
                cnt++;
                break;
            }
        }
        if (fl == 1) {
            ls = 0;
            for (auto to : st1) {
                if (a[to.fi] != ls) {
                    if (to.fi == x) {
                        cout << cnt << "\n";
                        return;
                    }
                    ls = a[to.fi];
                    st.erase({to.fi, to.se});
                    if (to.fi + 1 <= to.se) {
                        st.insert({to.fi + 1, to.se});
                    }
                    fl = 0;
                    cnt++;
                    break;
                }
            }
        }
    }
}

int32_t main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // LOCAL

    cin >> n >> q;
    for (i = 1; i <= n; i++) cin >> a[i];

    while (q--) {
        cin >> tp;
        if (tp == 1) {
            cin >> x;
            swap(a[x], a[x + 1]);
        } else {
            cin >> h;
            f(h);
        }
    }
    return 0;
}
