#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define el '\n'
#define ff first
#define ss second
#define pb push_back
#define point pair <ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const ll N = 5e5 + 10;
const ll inf = 1e18 + 10;

ll a[N];

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

    ll n, q;
    cin >> n >> q;

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

    while (q--) {
        ll t, x, l, r;
        cin >> t;

        if (t == 1) {
            cin >> x;
            a[x] *= -1;
        } else {
            cin >> l >> r;
            cout << r - l + 1 << el;
        }
    }

    return 0;
}
