N, Q = [int(x) for x in input().split()]
s = list(str(input()))

# LR_dict = {'L':-1, 'R':1}
t_list = []
d_list = []
for x in range(Q):
  t, d = [str(x) for x in input().split()]
  t_list.append(t)
  d_list.append(d)

dict_ = {}
for idx, s_ in enumerate(s):
  if s_ not in dict_:
  	dict_[s_] = {}
  dict_[s_][idx] = {}

dict_[s[0]][0] = {'n' : 1, 'l' : 'END', 'r' : s[1]}
for idx, (s_l, s_, s_r) in enumerate(zip(s[:-2], s[1:-1], s[2:])):
  dict_[s_][idx+1]['n'] = 1
  dict_[s_][idx+1]['l'] = s_l
  dict_[s_][idx+1]['r'] = s_r
dict_[s[N-1]][N-1] = {'n' : 1, 'l' : s[-2], 'r' : 'END'}

i = 0
for t, d in zip(t_list, d_list):
  if t not in dict_.keys():
    break
  if d == 'L':
    for key, val in sorted(dict_[t].items()):
      if val['l'] == 'END':
        pass
      else:
        dict_[val['l']][key-1]['n'] += val['n']
      dict_[t][key]['n'] = 0
  if d == 'R':
    for key, val in sorted(dict_[t].items(), reverse=True):
      if val['r'] == 'END':
        pass
      else:
        dict_[val['r']][key+1]['n'] += val['n']
      dict_[t][key]['n'] = 0

S=0
for key, val in dict_.items():
  for key_, val_ in val.items():
    S += val_['n']
print(S)