N,Q=map(int,input().split())
s=list(input())
jyotai=[1]*N

#eioomoji=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

dict={"A":[],"B":[],"C":[],"D":[],"E":[],"F":[],"G":[],"H":[],"I":[],"J":[],"K":[],"L":[],"M":[],"N":[],"O":[],"P":[],"Q":[],"R":[],"S":[],"T":[],"U":[],"V":[],"W":[],"X":[],"Y":[],"Z":[]}


for j in range(N):
  tmplist=dict[s[j]]
  tmplist.append(j)
  dict[s[j]]=tmplist
  
for i in range(Q):
  t,d=input().split()
  taisyolist=dict[t]
  for j in taisyolist:
      if d=="R":
        if not j==N-1:
          jyotai[j+1]+=jyotai[j]
        jyotai[j]=0
      else:
        if not j==0:
          jyotai[j-1]+=jyotai[j]
        jyotai[j]=0

print(sum(jyotai))
