#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, ls;
    for (i = 1; i <= n; i++) fl[i] = 0;
    ls = 0;
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            if (a[j] != ls && fl[j] == 0) {
                fl[j] = 1;
                if (j == x) {
                    cout << i << endl;
                    return;
                }
                ls = a[j];
                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;
}
