import numpy as np
N, Q = (int(i) for i in input().split())
masu = input()
masu = {x:[i+1 for i in range(N) if masu[i] == x] for x in set(masu)}
golem = np.array([0]+[1 for _ in range(N)]+[0])
for _ in range(Q):
    spell = input().split()
    if spell[0] not in masu.keys():
        continue
    indices = np.array(masu[spell[0]])
    temp = golem[indices]
    golem[indices+ (1 if spell[1]=='R' else -1)] += temp
    golem[indices] -= temp 
    
print(sum(golem[1:-1]))