import numpy as np

n, q = [int(_) for _ in input().split()]

s = input()
s_map = {'A':0, 'B':1, 'C':2, 'D':3, 'E':4, 'F':5,'G':6,'H':7,'I':8,'J':9,'K':10,'L':11,
          'M':12, 'N':13 ,'O':14, 'P':15,'Q':16,'R':17,'S':18,'T':19,'U':20,'V':21,'W':22,'X':23,'Y':24,'Z':25}

indlist = [[0]*n for _ in range(26)]
for i in range(n):
    indlist[s_map[s[i]]][i] = 1

np_ind_pre = [np.array(ind) for ind in indlist]
np_ind = np.array(np_ind_pre)

t_ = []
d = []
for i in range(q):
    ti, di = input().split()
    t_.append(s_map[ti])
    d.append(di)
t = np.array(t_)

gs = np.ones(n)

for i in range(q):
    if d[i] == 'L':
        tmp1 = gs * np_ind[t[i]]
        gs = gs - tmp1
        tmp2 = np.append(tmp1[1:], 0)
        gs = gs + tmp2
    else:
        tmp1 = gs * np_ind[t[i]]
        gs = gs - tmp1
        tmp2 = np.insert(tmp1[:-1], 0, 0)
        gs = gs + tmp2
print(int(gs.sum()))


