//BISMILLAHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200009];
int main()
{
       ll n,i,tt,x1=0,x2=0,x,kk,q;
       cin>>n>>q;
       for(i=1; i<=n; i++)
       {
        cin>>a[i];
        if(a[i]==1)
            x1++;
        else
            x2++;

       }
       for(i=1; i<=q; i++)
       {
           cin>>tt;
           if(tt==1)
           {
               cin>>x;
               if(a[x]==0)
               {
                   x2--;
                   a[x]=1;
                   x1++;
               }
               else
               {
                    x2++;
                   a[x]=0;
                   x1--;
               }
           }
           else
           {
               cin>>kk;
               if(x1>=kk)
               {
                   cout<<"1"<<endl;
               }
               else
                cout<<"0"<<endl;
           }
       }



   }

//ALHAMDULILLA
