#include <bits/stdc++.h>
using  namespace std;
#define all(x) x.begin(), x.end()
using ll = long long;
using sll = __int128;
using ld = long double;
const ll inf = 1e18;
void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int qi = 0; qi < q; ++qi) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            swap(a[x], a[x + 1]);
        }
        else {
            int y;
            cin >> y;
            deque<int> dq;
            int c = -1;
            int dc = -1;
            vector<int> res;
            for (int i = 1; i <= n;) {
                if (a[i] == c) {
                    if (c == dc || dq.empty()) {
                        dq.push_back(i);
                        i++;
                        dc = c;
                    }
                    else {
                        res.push_back(dq.front());
                        dq.pop_front();
                        c = dc;
                    }
                }
                else {
                    if (c == dc || dq.empty()) {
                        c = a[i];
                        res.push_back(i);
                        i++;
                    }
                    else {
                        res.push_back(dq.front());
                        dq.pop_front();
                        c = dc;
                    }
                }
            }
            while (!dq.empty()) {
                res.push_back(dq.front());
                dq.pop_front();
            }
            for (int i = 0; i < n; ++i) {
                if (res[i] == y) {
                    cout << i + 1 << '\n';
                    break;
                }

            }
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}