import numpy as np 
N, Q = list(map(int, input().split()))
s = list("_" + input() + "_")
gms = np.ones(len(s),dtype=np.int16)
gms[0] = 0
gms[-1] = 0

word_dict = dict()
for i,w in enumerate(s):
    if w in word_dict:
        word_dict[w].append(i)
    else:
        word_dict[w] = [i]
for i in range(Q):
    t_i, d_i = input().split()
    if not t_i in word_dict:
        continue
    if d_i == "L":
        move = -1
    else:
        move = 1
    source = np.array(word_dict[t_i])
    target = source + move
    gms[target] += gms[source]
    gms[source] = 0
    #print(gms)

#print(gms)

print(N - gms[0] - gms[-1])
