#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int q; cin >> q;
    vector<int> a;
    vector<int> b;
    vector<int> col(n);
    int now = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        col[i] = x;
        if (i == 0) {
            now = x;
            continue;
        }
        if (x == 2) {
            b.push_back(i);
        } else {
            a.push_back(i);
        }
    }
    vector<int> ans(n, -1);
    int i = 0, j = 0;
    ans[0] = 1;
    int cnt = 1;
    while (i < a.size() && j < b.size()) {
        if (now == 2) {
            ans[a[i]] = ++cnt;
            i++;
            now = 1;
        } else {
            ans[b[j]] = ++cnt;
            j++;
            now = 2;
        }
    }
    for (int i = 0; i < n; i++) {
        if (ans[i] == -1) ans[i] = ++cnt;
    }
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x; cin >> x;
            if (col[x] == col[x - 1]) continue;
            swap(col[x], col[x - 1]);
            swap(ans[x], ans[x - 1]);
        } else {
            int y; cin >> y;
            cout << ans[y - 1] << "\n";
        }
    }

}