n, q = map(int, raw_input().split())
s = raw_input()
g1 = [1] * n
for _ in range(q):
    t, d = raw_input().split()
    g2 = [0] * n
    for i in range(n):
        if s[i] != t:
            g2[i] += g1[i]
        elif d == 'L' and i > 0:
            g2[i - 1] += g1[i]
        elif d == 'R' and i < n - 1:
            g2[i + 1] += g1[i]
    g1 = g2
print sum(g1)