#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
#define int long long

vector<int> answer(vector<int> nums) {
    vector<int> one, two;
    for (int i = 0; i < nums.size(); i++) {
        if (nums[i] == 1) one.push_back(i);
        if (nums[i] == 2) two.push_back(i);
    }
    vector<int> answer(nums.size(), 0);
    int i = 0;
    int j = 0;
    answer[0] = 1;
    int now = 0;
    if (nums[0] == 1) {
        i++;
        now = 1;
    }
    if (nums[0] == 2) {
        j++;
        now = 2;
    }
    int k = 2;
    while (i < one.size() && j < two.size()) {
        if (now == 1) {
            answer[two[j]] = k;
            k++;
            j++;
            now = 2;
        } else if (now == 2) {
            answer[one[i]] = k;
            k++;
            i++;
            now = 1;
        } else {
            exit(228);
        }
    }
    for (; i < one.size(); i++) {
        answer[one[i]] = k;
        k++;
    }
    for (; j < two.size(); j++) {
        answer[two[j]] = k;
        k++;
    }
    return answer;
}

signed main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);

    int n, q;
    cin >> n >> q;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) cin >> nums[i];
    vector<int> now = answer(nums);
    // for (int i : nums) cout << i << ' ';
    // cout << '\n';
    // for (int i : now) cout << i << ' ';
    // cout << '\n';
    // cout << '\n';
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x;
            cin >> x;
            x--;
            if (nums[x] != nums[x + 1]) {
                swap(now[x], now[x + 1]);
                swap(nums[x], nums[x + 1]);
                if (x == 0) {
                    now = answer(nums);
                }
            }
            // for (int i : nums) cout << i << ' ';
            // cout << '\n';
            // for (int i : now) cout << i << ' ';
            // cout << '\n';
            // for (int i : answer(nums)) cout << i << ' ';
            // cout << '\n';
            // cout << '\n';
        } else if (t == 2) {
            int y;
            cin >> y;
            y--;
            cout << now[y] << '\n';
        }
    }
}
