#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(NULL);
    ll n, q, a[100001], count[2], t, x;
    cin >> n >> q;
    count[0] = count[1] = 0;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        count[a[i]]++;
    }
    while (q--) {
        cin >> t >> x;
        if (t == 1) {
            if (a[x - 1]) 
                count[0]++, count[1]--, a[x-1] = 0;
            else 
                count[0]--, count[1]++, a[x-1] = 1;
        }
        else {
            if (x <= count[1])
                cout << 1 << endl;
            else 
                cout << 0 << endl;
        }
    }
 	return 0;
}