n,q=map(int,input().split())
s=list(input())
l=[list(input().split()) for i in range(q)]
L1=0;R1=n-1
while L1!=R1:
  x1=(L1+R1)//2
  p=x1
  for i in range(q):
    if l[i][0]==s[p]:
      if l[i][1]=='L':
        p-=1
      else:
        p+=1
    if p==-1 or p==n:
      break
  if p==-1:
    L1=x1+1
  else:
    R1=x1

L2=0;R2=n-1
while L2!=R2:
  x2=(L2+R2+1)//2
  p=x2
  for i in range(q):
    if l[i][0]==s[p]:
      if l[i][1]=='L':
        p-=1
      else:
        p+=1
    if p==-1 or p==n:
      break
  if p==n:
    R2=x2-1
  else:
    L2=x2

print(L2-L1+1)