import string


N, Q = map(int, input().split())
s = input()
golem = [0]
golem.extend([1] * N + [0])

loc = {}
for c in string.ascii_uppercase:
    loc[c] = []

for i, c in enumerate(s):
    loc[c].append(i+1)

for _ in range(Q):
    t, d = input().split()
    for i in loc[t]:
        num = golem[i]
        golem[i] = 0
        if d == 'L':
            golem[i-1] += num
        else:
            golem[i+1] += num

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