#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
#define super ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define cn cout<<"NO"<<endl;
#define cy cout<<"YES"<<endl;
using namespace std;
int main()
{
    super;
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,q;
        cin>>n>>q;
        ll ones=0,zeros=0;
        int arr[n];
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
            if(arr[i]==1)
            {
                ones++;
            }
            else
            {
                zeros++;
            }
        }
        for(int i=0;i<q;i++)
        {
            int ty;
            cin>>ty;
            if(ty==1)
            {
                int pos;
                cin>>pos;
                if(arr[pos-1]==0)
                {
                    arr[pos-1]=1;
                    ones++;
                    zeros--;
                }
                else
                {
                    arr[pos-1]=0;
                    zeros++;
                    ones--;
                }
            }
            else
            {
                int kth;
                cin>>kth;
                //cout<<zeros<<" "<<ones<<endl;
                if(ones>=kth)
                {
                    cout<<1<<endl;
                }
                else
                {
                    cout<<0<<endl;
                }
            }
        }
    }
}



