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

P = [[] for _ in range(ord('Z') - ord('A') + 1)]
for i in range(N):
  p = ord(S[i]) - ord('A')
  P[p].append(i)

dG = [0 for _ in range(N)]
G = [1 for _ in range(N)]
for i in range(Q):
  t,d = input().split()
  ti = ord(t) - ord('A')
  
  for j in P[ti]:
    g = G[j]
    G[j] = 0
    dG[j] = g
  for j in P[ti]:
    dg = dG[j]
    if ('L' == d):
      if (0 < j):
        G[j-1] += dg
    elif ('R' == d):
      if (j < (N-1)):
        G[j+1] += dg
print(sum(G))
