
from collections import defaultdict

N, Q = input().split(' ')
N, Q = int(N), int(Q)
S = input().replace('\r', '').replace('\n', '')

char_map = defaultdict(list)
for i, ch in enumerate(S):
    char_map[ch].append(i)

gorem_list = [1 for ch in S]
for i in range(Q):
    t, d = input().replace('\r', '').replace('\n', '').split(' ')
    if d == 'R':
        direction = 1 
    elif d == 'L':
        direction = -1

    for j in char_map[t]:
        dest = j + direction
        if dest >= 0 and dest < N:
            gorem_list[dest] += gorem_list[j]

        gorem_list[j] = 0


print(sum(gorem_list))
