#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--;
            vector<int> b;
            for (int i = l; i < r; i++) {
                b.push_back(a[i]);
            }
            int k = len(b);

            int curr = 0;
            vector<int> c;
            for (int i = 0; i < k; i++) {
                curr += b[i];
                if (curr < 0) {
                    curr++;
                }
                else {
                    c.push_back(b[i]);
                }
            }
            b = c;
            c.clear();
            reverse(all(b));
            curr = 0;
            k = len(b);
            for (int i = 0; i < k; i++) {
                curr += b[i];
                if (curr < 0) {
                    curr++;
                }
                else {
                    c.push_back(b[i]);
                }
            }
            cout << len(c) << '\n';
        }
    }
}

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

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