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)]
tds = []
for _ in range(q):
    tds.append(tuple(input().split()))
for t, d in tds:
    for i in indices.get(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))