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

dic = {}
for i in range(N+2):
    dic[S[i]] = dic.get(S[i],[]) + [i] 
    
table = [0] + [1]*N + [0]
for _ in range(Q):
    t,d = input().split()
    if t not in dic:
        continue
    if d == "L":                
        for i in dic[t]:
            table[i-1] += table[i] 
            table[i] = 0
    else:   
        for i in dic[t]:
            table[i+1] += table[i]
            table[i] = 0
print(sum(table[1:N+1]))
