n,q=map(int,input().split())
s=list(input())
stage=[1]*n
for i in range(q):
  v = input().split()
  for j in range(n):
    if s[j]==v[0]:
      if v[1]=="L":
        if j!=0:
          stage[j-1]+=stage[j]
        stage[j]=0
      else:
        if j!=n-1:
          stage[j+1]+=stage[j]
        stage[j]=0
print(sum(stage))