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

//#define int long long
#define ll long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ff first
#define ss second

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> used(n, 0);
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            cin >> i;
            swap(a[i - 1], a[i]);
        } else {
            int y;
            cin >> y;
            --y;

            used.assign(n, 0);
            int pr = -1;
            int ans = 0;
            for (int j = 0; j < n; ++j) {
                bool f = false;
                for (int i = 0; i < n; ++i) {
                    if (!used[i] && a[i] != pr) {
                        used[i] = j + 1;
                        pr = a[i];
                        f = true;
                        break;
                    }
                }
                if (used[y]) {
                    ans = used[y];
                    break;
                }
                if (!f) {
                    ans = y + 1;
                    break;
                }
            }
            cout << ans << '\n';
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
