n,q = [int(i) for i in input().split()]
S = input()

td = []
for i in range(q):
  td.append([i for i in input().split()])
  if td[-1][1] == 'L':
    td[-1][1] = -1
  else:
    td[-1][1] = 1

s_index = {}
for i,s in enumerate(S):
  if s in s_index.keys():
    s_index[s].append(i)
  else:
    s_index[s] = [i]
  
gore = [1]*n

for t,d in td:
  if t not in s_index.keys():
    continue
  t_index = s_index[t]
  for i in t_index:
    if i+d <= -1 or n <= i+d:
      gore[i] = 0
    else:
      tmp= gore[i]
      gore[i] = 0
      gore[i+d] += tmp
      
gore_sum = sum(gore)
print(gore_sum)
  
  
