#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 3e18;

ll mmod(ll x, ll mod = MOD) {
    x = x%MOD;
    if (x < 0) {
        x += MOD;
    }
    return x;
}

ll binpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n&1) {
            res= res*a % MOD;
        }
        a = a*a%MOD;
        n >>=1;
    }
    return res;

}


void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < q; ++i) {
        ll c;
        cin >> c;
        if (c == 1) {
            ll x;
            cin >> x;
            x--;
            swap(a[x], a[x+1]);
        } else {
            ll x;
            cin >> x;
            x--;
            ll cur = -1;
            vector<bool> used(n, 0);
            bool f =1;
            ll cnt = 0;
            for (int j = 0; j < n; ++j) {
                if (cnt != j) {
                    break;
                }
                for (int h = 0; h < n; ++h) {
                    if (!used[h] && a[h] != cur) {
                        if (x == h) {
                            cout << j + 1 << '\n';
                            f = 0;
                            break;
                        } else {
                            used[h] = 1;
                            cur = a[h];
                            cnt++;
                            break;
                        }
                    }
                }
                if (!f) {
                    break;
                }
            }
            if (cnt != n && f == 1) {
                for (int j = 0; j < n; ++j) {
                    if (!used[j]) {
                        if (j == x) {
                            cout << cnt + 1 << '\n';
                            break;
                        } else {
                            used[j] = 1;
                            cnt++;
                        }
                    }
                }
            }
        }
    }

}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("C:\\work\\untitled\\in.txt", "r", stdin);
    // freopen("C:\\work\\untitled\\out.txt", "w", stdout);

    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << '\n';
    }
}