import re

N, Q = map(int, input().split())
s = input()
golems = [1] * len(s)

for _ in range(Q):
    t, d = input().split()
    for match in re.finditer(t, s):
        idx = match.start()
        if d == 'L' and idx != 0:
            golems[idx - 1] += golems[idx]
        elif d == 'R' and idx != len(s) - 1:
            golems[idx + 1] += golems[idx]

        golems[idx] = 0

print(sum(golems))