N, Q  = [int(a) for a in input().split()]
s = input()
s_dict = {c:[] for c in set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')}
for i, c in enumerate(s):
    s_dict[c].append(i+1)
g = [1] * (N+2)

for _ in range(Q):
    row = input()
    c, lr = row.split()
    for i in s_dict[c]:
        mover = g[i]
        g[i] -= mover
        if lr == 'L':
            g[i-1] += mover
        else:
            g[i+1] += mover

print(sum(g[1:-1]))