#include <iostream>
#include <vector>
using namespace std;
const int N = (1<<20) + 1;
int a[N], ind[N], vd[N], T;
struct sgmt{
int tm = 0, L, R, bg, tp;
} seg[N<<1], ans, Null;
void Add1(sgmt S, int cur = 1, int st = 1, int en = N){
if (S.L >= en or S.R <= st)
return;
if (S.L <= st and S.R >= en){
seg[cur] = S;
return;
}
int mid = (st + en) / 2;
Add1(S, cur + cur, st, mid);
Add1(S, cur+cur+1, mid, en);
}
void get(int i, int cur = 1, int st = 1, int en = N){
if (i >= en or i < st)
return;
if (seg[cur].tm > ans.tm)
ans = seg[cur];
if (en - st == 1)
return;
int mid = (st + en) / 2;
get(i, cur + cur, st, mid);
get(i, cur+cur+1, mid, en);
}
pair<int, int> extend(int l, int r){
// cout<<l<<' '<<r<<' '<<endl;
if (a[l] < a[r]){
// cout<<"here ";
int v = a[r];
while (vd[ind[v]] or ind[v] >= l)
v++;
// cout<<v<<' '<<ind[v]<<endl;
Add1({++T, ind[v]+1, l+1, r - l, 1});
l = ind[v];
}
else{
int v = a[l];
while (vd[ind[v]] or ind[v] <= r)
v++;
Add1({++T, r, ind[v], r - l, 0});
r = ind[v];
}
return {l, r};
}
int main(){
int n, A, B, q, nxt = 0;
cin>>n>>A;
for (int i=1;i<=n;i++)
cin>>a[i], ind[a[i]] = i, nxt++;
ind[++nxt] = 0, a[0] = nxt;
ind[++nxt] = n+1, a[n+1] = nxt;
vector<pair<int, int>> rec;
Add1({++T, A, A+1, 1, 0});
rec.push_back({A-1, A+1});
while (rec.back().second - rec.back().first < n + 1)
rec.push_back(extend(rec.back().first, rec.back().second));
cin>>q;
for (int i=1, id, e;i<=q;i++){
char c;
cin>>c;
if (c == 'E'){
cin>>id>>e, e += 2;
for (int j=0;j<e-1;j++)
a[ind[nxt - j]]++, ind[nxt - j + 1] = ind[nxt - j + 1];
vd[ind[a[id]]] = 1;
nxt++;
a[id] = nxt - e;
if (id == A)
continue;
while (rec.back().second > id and rec.back().first < id)
rec.pop_back();
while (rec.back().second - rec.back().first < n + 1)
rec.push_back(extend(rec.back().first, rec.back().second));
}
else{
cin>>B;
ans = Null;
get(B);
if (ans.tp == 1)
cout<<ans.bg + ans.R - B - 1<<'\n';
else
cout<<ans.bg + B - ans.L<<'\n';
}
}
}