N, Q = list(map(int,input().split()))
S = list(input())
G = [1 for i in range(N)]
for j in range(Q):
  data = input().split()
  for i in range(N):
    if S[i] == data[0]:
      if data[1] == 'L':
        if i != 0:
          G[i-1] += G[i]
      if data[1] == 'R':
        if i != N-1:
          G[i+1] += G[i]
      G[i] = 0
print(sum(G))