N,Q=map(int,input().split())
s=list(input())
jyotai=[1]*N

for i in range(Q):
  t,d=input().split()
  for j in range(N):
    if s[j]==t:
      if d=="R":
        if not j==N-1:
          jyotai[j+1]+=jyotai[j]
        jyotai[j]=0
      else:
        if not j==0:
          jyotai[j-1]+=jyotai[j]
        jyotai[j]=0
print(sum(jyotai))