import copy

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

char_map = {}
for i in range(N):
    if s[i] not in char_map:
        char_map[s[i]] = []
    char_map[s[i]].append(i)
T = []
D = []

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

before = [1] * N

for i in range(0, Q):
    after = copy.copy(before)
    if T[i] not in char_map:
        continue
    for j in char_map[T[i]]:
        after[j] -= before[j]
        if D[i] == 'L':
            if j >= 1:
                after[j-1] += before[j]
        else:
            if j <= N-2:
                after[j+1] += before[j]
    before = after

print(sum(after))