#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int pop_count(int x){
int cnt=0;while(x) x-=(x&(-x)),cnt++;return cnt;
}
const int N=3e5+5;
int n,m,a[N];
struct nd{
int l,r,val,flag;
}c[N<<2];
void pushup(int pos){
if(c[pos<<1].val+c[pos<<1].flag==c[pos<<1|1].val+c[pos<<1|1].flag) c[pos].val=c[pos<<1].val+c[pos<<1].flag;
else c[pos].val=-1;
}
void build(int pos,int l,int r){
c[pos].l=l,c[pos].r=r,c[pos].val=-1;
if(l==r) {
c[pos].val=a[l];
return ;
}
build(pos<<1,l,(l+r)/2);
build(pos<<1|1,(l+r)/2+1,r);
pushup(pos);
}
void pushdown(int pos){
if(c[pos].val!=-1) {
c[pos].val+=c[pos].flag;
c[pos<<1].val=c[pos<<1|1].val=c[pos].val;
c[pos<<1].flag=c[pos<<1|1].flag=c[pos].flag=0;
return ;
}
c[pos<<1].flag+=c[pos].flag;
c[pos<<1|1].flag+=c[pos].flag;
c[pos].flag=0;
}
void ask(int pos,int x){
if(c[pos].l>x||c[pos].r<x) return ;
if(c[pos].l==c[pos].r){
cout<<c[pos].val+c[pos].flag<<"\n";
return ;
}pushdown(pos);
ask(pos<<1,x);ask(pos<<1|1,x);
pushup(pos);
}
void add(int pos,int l,int r,int x){
if(c[pos].l>r||c[pos].r<l) return ;
if(l<=c[pos].l&&c[pos].r<=r){
c[pos].flag+=x;
return ;
}pushdown(pos);
add(pos<<1,l,r,x);
add(pos<<1|1,l,r,x);
pushup(pos);
}
void query(int pos,int l,int r){
if(c[pos].l>r||c[pos].r<l) return ;
if(c[pos].val!=-1&&l<=c[pos].l&&c[pos].r<=r){
c[pos].val=pop_count(c[pos].val+c[pos].flag);
c[pos].flag=0;
return ;
}pushdown(pos);
query(pos<<1,l,r);
query(pos<<1|1,l,r);
pushup(pos);
}
signed main(){
cin.tie(0)->sync_with_stdio(false);
cin>>n>>m;for(int i=1;i<=n;i++) cin>>a[i];
build(1,1,n);
for(int i=1;i<=m;i++){
char opt;int l,r,x;
cin>>opt;
if(opt=='J') {cin>>x;ask(1,x);}
else if(opt=='A'){
cin>>l>>r>>x;
add(1,l,r,x);
}
else {
cin>>l>>r;
query(1,l,r);
}
}
return 0;
}