# coding: utf-8

N, Q = map(int, input().split())
S = input()

tile = {} # 文字マップ
now = [1] * N

for s in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
  tile.setdefault(s, [])

for i in range(len(S)):
  tile[S[i]].append(i)

for i in range(Q):
  t, d = input().split()
  if d == "L":
    for j in tile[t]:
      if j != 0:
        now[j-1] += now[j]
      now[j] = 0
  else:
    for j in tile[t]:
      if j != N-1:
        now[j+1] += now[j]
      now[j] = 0

print(sum(now))