#マスの長さ，呪文の回数
N,Q = map(int, input().split())
square_str = str(input())
#ABC
square_list = list(square_str)
#ゴーレムの数
num_list = [1]*N
for i in range(Q):
  t,d = map(str,input().split())
  for j in range(N):
    if t != square_list[j]:
      continue
    if num_list[j] != 0:
      move = num_list[j]
      num_list[j] = 0
      if d == 'R' and j < N-1:
        num_list[j+1] += move
      elif d == 'L' and j > 0:
        num_list[j-1] += move
print(sum(num_list))