import numpy as np

N, Q = tuple([int(x) for x in str(input()).split(' ')])

s = input()
M = list(set(s))
numM = len(M)
M_dict = {m : i for i, m in enumerate(M)}

data = np.ones((len(M), N), float)


for i, m in enumerate(M):
    for j in range(N):
        if s[j] != m:
            data[i, j] = np.nan

for i in range(Q):
    t, d = tuple([x for x in str(input()).split(' ')])
    if t in M_dict.keys():
        j = M_dict[t]
        if d == 'L':
            tmp = np.stack([np.nan_to_num(data[j, 1:])] * numM)
            data[j, :] *=0
            data[:, :-1] += tmp
        else:
            tmp = np.stack([np.nan_to_num(data[j, :-1])] * numM)
            data[j, :] *=0
            data[:, 1:] += tmp

print(int(sum(sum(np.nan_to_num(data)))))