#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
#pragma GCC target("avx", "avx2")

using ll = long long;
using lll = __int128;
using dd = long double;
using para = pair <ll, ll>;
using parad = pair <dd, dd>;
const ll maxn = 500000;
ll used[maxn];
ll cntu = 1;
vector <ll> f(const vector <ll>& a) {
    vector <ll> ans;
    ans.push_back(0);
    ll n = a.size();
    cntu++;
    used[0] = cntu;
    for (ll i = 1; i < n; ++i) {
        bool fl = false;
        ll col = a[ans.back()];
        for (ll j = 1; j < n; ++j) {
            if (used[j] != cntu && a[j] != col) {
                ans.push_back(j);
                fl = true;
                used[j] = cntu;
                break;
            }
        }
        if (!fl) {
            for (ll j = 1; j < n; ++j) {
                if (used[j] != cntu) {
                    ans.push_back(j);
                    used[j] = cntu;
                }
            }
            break;
        }
    }
    return ans;
}
void solvetask() {
    ll n, q;
    cin >> n >> q;
    vector <ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]--;
    }
    vector <ll> ans = f(a);
    ll cnt = 0;
    while (q--) {
        ll type, x;
        cin >> type >> x;
        x--;
        if (type == 1) {
            swap(a[x], a[x + 1]);
            cnt++;
        } else {
            if (cnt > 0) {
                ans = f(a);
                cnt = 0;
            }
            for (ll i = 0; i < n; ++i) {
                if (ans[i] == x) {
                    cout << i + 1 << "\n";
                    break;
                }
            }
        }
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll tests = 1;
    //cin >> tests;
    while (tests--) {
        solvetask();
    }
    return 0;
}