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

T = []
D = []

for i in range(Q):
    t, d = input().split()
    T.append(t)
    D.append(d)

P = [[0] * N for i in range(Q+1)]

for i in range(N):
    P[0][i] = 1

for i in range(1, Q+1):
    for j in range(N):
        P[i][j] = P[i-1][j]
        if T[i-1] == s[j]:
            P[i][j] = 0

        if j <= N-2 and s[j+1] == T[i-1] and D[i-1] == 'L':
            P[i][j] += P[i-1][j+1]

        if j >= 1 and s[j-1] == T[i-1] and D[i-1] == 'R':
            P[i][j] += P[i-1][j-1]

print(sum(P[Q]))