#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define endl '\n'

int dp[101][201][201];

int main(){
    ll n, q;
    cin >> n >> q;

    vector<ll> a(n + 1);
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    while(q--){
        ll type;
        cin >> type;

        if(type == 1){
            ll p;
            cin >> p;

            a[p] = -a[p];
        }
        else{
            ll l, r;
            cin >> l >> r;

            if(a[l] == -1)
                l++;
            if(a[r] == -1)
                r--;

            cout << max(0ll, r - l + 1) << endl;
        }
    }

    return 0;
}

/*
5 1
1 1 1 -1 1
2 1 5

*/
