N, Q = input().split()
N = int(N)
Q = int(Q)
s = input()
sv = [1 for i in range(N)]
sv = [0] + sv
sv = sv + [0]

for i in range(Q):
  ss = input().split()
  for j,v in enumerate(s):
    if(ss[0]==v):
      if(ss[1]=='L'): sv[j]+=sv[j+1]
      else: sv[j+2]+=sv[j+1]
      sv[j+1]=0
      sv[0]=0
      sv[-1]=0

print(sum(sv))