N,Q = map(int,input().split())
s = input()
ans = [1]*(len(s)+2)

for i in range(Q):
  t,d = input().split()
  index_ = [i for i, x in enumerate(s) if x == t]
  for i in index_:
    index = i+1
    if d == 'L':
      ans[index-1]+=ans[index]
      ans[index]=0
    else:
      ans[index+1]+=ans[index]
      ans[index]=0
print(sum(ans[1:len(s)+1]))
  