#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

void func1(vector<int>& A, int i)
{
    A[i] = -A[i];
}

int func2(vector<int>& A, int l, int r)
{
    int c = r-l+1;
    if (A[l] == -1) c--;
    if (A[r] == -1) c--;
    return c;
}

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

    vector<int> A(n+1);
    for (int i=1; i<=n; i++)
    {
        cin >> A[i];
    }

    int type, p, l, r;
    for (int w=0; w<q; w++)
    {
        cin >> type;
        if (type == 1)
        {
            cin >> p;
            
        }
        else
        {
            cin >> l >> r;
            cout << func2(A, l, r) << endl;
        }
    }
}