import numpy as np
#マスの長さ，呪文の回数
N,Q = map(int, input().split())
square_str = str(input())
#ABC
square = list(square_str)
#ゴーレムの数
num_list = np.ones(N,dtype="int8")
for i in range(Q):
  t,d = map(str,input().split())
  for j in range(len(square)):
    if square[j] == t and num_list[j] != 0:
      move = num_list[j]
      num_list[j] = 0
      if 0 < j and j < N-1:
        if d == 'R':
          num_list[j+1] += move
        else:
          num_list[j-1] += move
print(sum(num_list))