n, q = map(int, input().split())
s = input()
ls = [1] * n
for _ in range(q):
    t, d = input().split()
    ts = [0] * n
    if d == "L":
        for i in range(n-1, -1, -1):
            if s[i] == t:
                if i == 0:
                    ls[i] = 0
                else:
                    ts[i - 1] = ls[i]
                    ls[i] = 0
    else:
        for i in range(n):
            if s[i] == t:
                if i == n-1:
                    ls[i] = 0
                else:
                    ts[i + 1] = ls[i]
                    ls[i] = 0
    for i in range(n):
        ls[i] += ts[i]
            

print(sum(ls))