n,q=map(int,input().split())
s=input()
td=[input().split()for _ in range(q)]
def check(i,x):
  for t,d in td:
    if s[i]==t:
      if d=="L":i-=1
      else:i+=1
    if i==x:return True
    if i==-1 or i==n:return False
  return False
ok=-1
ng=n
while ok+1!=ng:
  mid=(ok+ng)//2
  if check(mid,-1):ok=mid
  else:ng=mid
ans=ng
ok=-1
ng=n
while ok+1!=ng:
  mid=(ok+ng)//2
  if check(mid,n):ng=mid
  else:ok=mid
ans+=(n-ng)
print(max(0,n-ans))