N, Q = map(int, input().split())
s = input()

G = [1 for i in range(N+2)]

for q in range(Q):
    t, d = input().split()
    for n in range(N):
        if d == 'L':
            if t == s[n]:
                G[n] += G[n + 1]
                G[n + 1] = 0
        else:
            n_ = N - 1 - n
            if t == s[n_]:
                G[n_ + 2] += G[n_ + 1]
                G[n_ + 1] = 0

print(sum(G[1:len(G)-1]))