n, q = map(int, input().split())
s = input()
indices = {}
for i in range(n):
    indices.setdefault(s[i], [])
    indices[s[i]].append(i)
g = [1 for _ in range(n)]
for _ in range(q):
    t, d = input().split()
    for i in indices.get(t, []):
        if s[i] == t:
            if d == 'L':
                if i != 0:
                    g[i-1] += g[i]
            else:
                if i != n-1:
                    g[i+1] += g[i]
            g[i] = 0
print(sum(g))