N,Q=map(int,input().split())
S="#"+input()+"#"
qs=[[i for i in input().split()] for i in range(Q)]
L,R=0,N+1
for t,d in qs[::-1]:
  if d=="L":
    if S[L+1]==t:
      L+=1
    if S[R]==t:
      R+=1
  else:
    if S[L]==t:
      L-=1
    if S[R-1]==t:
      R-=1
print(R-L-1)