N, Q = input().split()
N, Q = int(N), int(Q)
s = input()
t_l = []
d_l = []
for h in range(Q):
    t, d = input().split()
    t_l.append(t)
    d_l.append(d)

g_l = []
for i in range(N):
    g_l.append(1)

for j in t_l:
    if j in s:
        a = s.count(j)
        print('{}{}'.format('a=', a))
        for k in range(a):
            b = s.find(j, k)
            print('{}{}'.format('b=', b))
            if g_l[b] >= 1:
                g_l[b] = g_l[b] - 1
            if d_l[b] == 'L':
                if N - 1 >= b >= 1:
                    g_l[b - 1] = g_l[b - 1] + 1
            elif d_l[b] == 'R':
                if N - 2 >= b >= 0:
                    g_l[b + 1] = g_l[b + 1] + 1

g_l_i = [int(g) for g in g_l]
print(sum(g_l_i))

 # まだ正解してない
