n, q = [int(n) for n in input().split()]
s = input()
g = [0] + [1] * n + [0]

for i in range(q):
    t, d = input().split()

    for j in range(1, n + 1):
        if s[j-1] == t:
            if g[j] != 0:
                pre = g[j]

                g[j] = 0
                if d == 'L':
                    g[j-1] += pre
                else:
                    g[j+1] += pre
            else:
                continue
        else:
            continue

#print(g)        
print(sum(g[1:n+1]))