N, Q = (int(i) for i in input().split())  
s = input()
s="!"+s+"?"
spells = [input().split() for _ in range(Q)]
 
masu=[1]*(N+2)
for spell in spells:
   t=spell[0]
   d=spell[1]
   indexes = [i for i, x in enumerate(s) if x == t]
   for index in indexes:
      if d=="R":
         masu[index+1]+=masu[index]
         masu[index]=0
      else:
         masu[index-1]+=masu[index]
         masu[index]=0
      
   masu[0]=0
   masu[N+1]=0
   
 
masu.pop(0)
masu.pop(N)
print(sum(masu))