from collections import defaultdict
N,Q = map(int,input().split())
s = input()
ch = defaultdict(list)
i = 0
for s_1 in s:
    ch[s_1].append(i)
    i += 1
gohlem = [1] * N
for _ in range(Q):
    t, d = input().split()
    for mas in ch[t]:
        if d == 'L':
            if mas == 0:
                gohlem[0] = 0
            else:
                gohlem[mas - 1] =  gohlem[mas - 1] + gohlem[mas]
                gohlem[mas] = 0
        else:
            if mas == N - 1:
                gohlem[N - 1] = 0
            else:
                gohlem[mas + 1] =  gohlem[mas + 1] + gohlem[mas]
                gohlem[mas] = 0
print(sum(gohlem))

