def simulate(s,td,m):
  pos=m
  for i in range(q):
#    print(i,s[pos],td[i][0],pos)
    if s[pos]!=td[i][0]:
      continue
    if td[i][1]=='R':
      pos+=1
      if pos>n-1:
#        print("r fall")
        return 1
    else:
      pos-=1
      if pos<0:
#        print("l fall")
        return -1
  return 0
    
n,q=map(int,input().split())
s=input()
td=[input().split() for i in range(q)]

l=-1
r=n

while l+1<r:
  m=(l+r)//2
#  print("l=",l,"m=",m,"r=",r)
  if simulate(s,td,m)==-1:
    l=m
  else:
    r=m
left=r
#print("left",left)

l=-1
r=n
while l+1<r:
  m=(l+r)//2
  if simulate(s,td,m)==1:
    r=m
  else:
    l=m
right=n-1-l

print(n-left-right)

