n, q = (int(i) for i in input().split()) 
s = list(input())
td = [[i for i in input().split()] for i in range(q)]
e = [1] * (n+2)

for j in range(q) : 
 for i in range(n) : 
  if s[i]==td[j][0] and e[i+1]>0: 
   if td[j][1]=='R' : e[i+2] +=e[i+1]
   else : e[i] +=e[i+1]
   e[i+1] =0

count = 0
for k in range(n) : count += e[k+1]
print(count)