main(){
  system("python3 -c\"I=input;n,q=map(int,I().split());s=' %s '%I();l,r=0,n+1\nfor t,_,d in eval('I(),'*q)[::-1]:L=d<'R';R=1-L;l+=(t==s[l+1])*L-(t==s[l])*R;r+=(t==s[r])*L-(t==s[r-1])*R\nprint(r-l-1)\"");
}