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_l1 = []
g_l2 = []
for i in range(N):
    g_l1.append(1)
    g_l2.append(1)

for j in t_l:
    if j in s:
        a = s.count(j)
        for k in range(a):
            b = s.find(j, k)
             # c = g_l1[b] # g_l[b] = 0 の後でまた使うからcとしてとっとく
            g_l2[b] = 0
            if d_l[k] == 'L':
                if N - 1 >= b >= 1:
                    g_l2[b - 1] = g_l1[b - 1] + g_l1[b]
            elif d_l[k] == 'R':
                if N - 2 >= b >= 0:
                    g_l2[b + 1] = g_l1[b + 1] + g_l1[b]
            g_l1 = g_l2
g_l_i = [int(g) for g in g_l2]
print(sum(g_l_i) + 1)

 # まだ正解してない
