a,b = map(int,input().split())
s = str(input())
l = []
for i in range(a):
  l.append(1)
for i in range(b):
  t,u = map(str,input().split())
  for j in range(a):
    if s[j] == t:
      if u == 'L':
        if j == 0:
          l[j] = 0

        else:
          l[j-1]+= l[j]
          l[j] = 0
      else:
        if j == (a-1):
          l[j] = 0
        else:
          l[j+1]+= l[j]
          l[j] = 0
answer = 0
for i in range(len(l)):
  answer += l[i]
print(answer)
