n,q = map(int,input().split())
s = input()
g = [1]*n
td=[input().split() for _ in range(q)]
count = 0

for i in range(q):
  for j in range(n):
    if td[i][0]==s[j] and g[j]>0:
      if td[i][1]=="L":       
        if j-1 >= 0:
          g[j-1] += g[j]
        else:
          count += g[j]
        g[j] = 0 
      else:
        if j+1 < n:
          g[j+1] += g[j]
        else:
          count += g[j]
        g[j] = 0

print(n - count)  

