#include <bits/stdc++.h>
using namespace std;

#define int long long
#define len(v) (int) (v.size())
#define all(v) v.begin(), v.end()
#define rall(v) rbegin(v), rend(v)

istream& operator>>(istream& is, vector<int>& v) {
    for (int i = 0; i < len(v); i++) {
        is >> v[i];
    }
    return is;
}

ostream& operator<<(ostream& os, vector<int>& v) {
    for (int i = 0; i < len(v); i++) {
        os << v[i] << ' ';
    }
    return os;
}

const int INF = 1e12;

void solve() {
    int n, qn;
    cin >> n >> qn;
    vector<int> a(n);
    cin >> a;

    while (qn--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            cin >> i;
            i--;
            a[i] = -a[i];
        }
        else {
            int l, r;
            cin >> l >> r;
            l--, r--;
            int ans = r + 1 - l;
            if (a[l] == -1) ans--;
            if (a[r] == -1) ans--;
            cout << max(ans, 0ll) << '\n';
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}