n, q = map(int, input().split())
s = input()
L = [1 for i in range(n)] #カウント用
x = [list(input().split()) for i in range(q)]
S = [c  for c in s] #一文字ずつにわける
index = [i for i, x in enumerate(S) if x == 'C']
for i in range(q):
  index = [k for k, X in enumerate(S) if X == x[i][0]]
  for _, j in enumerate(index):
    if x[i][1]=='L':
      if j-1>=0:
        L[j-1] +=L[j]
        L[j] = 0
      else:
        L[j] = 0
    else:
      if (j+1)<=(n-1):
        L[j+1] +=L[j]
        L[j] = 0
      else:
        L[j] = 0

print(sum(L))
