n, q = map(int, input().split())
s = input()
L = [1 for i in range(n+2)] #カウント用
L[0] = -99999
L[n+1] = -99999
x = [list(input().split()) for i in range(q)]

S = [c  for c in s] #一文字ずつにわける

for i in range(q):
  index = [k for k, X in enumerate(S) if X == x[i][0]]
  for _, j in enumerate(index):
    if x[i][1]=='L':
        L[j+1-1] +=L[j+1]
        L[j+1] = 0
    else:
        L[j+1+1] +=L[j+1]
        L[j+1] = 0

print(sum(L[1:n+1]))