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
  for i in s_index[t][::-d]:
    if gore[i] == 0:
      continue
    if 0 <= i+d and i+d <= n-1:
      gore[i+d] += gore[i]      
    gore[i] = 0

gore_sum = sum(gore)
print(gore_sum)