#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define vll vector<ll>
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fr first
#define se second
#define pb push_back
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vbool vector<bool>
#define INF 10000000000000000

using namespace std;
using namespace __gnu_pbds;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n, q;
    cin >> n >> q;
    vll a(n);

    for (int i = 0; i < n; i ++) {
        cin >> a[i];
    }

    while (q --) {
        ll x, l, r;
        cin >> x;
        if (x == 1){
            cin >> l;
            l --;
            a[l] *= -1;
        }
        else {
            cin >> l >> r;
            l --;
            r --;
            ll res = r-l+1;
            if (a[l] == -1) res --;
            if (a[r] == -1 && l != r) res --;
            cout << res << endl;
        }
    }



}