n, q = [int(i) for i in input().split()]
s = input()
t_list = []
d_list = []
for i in range(q):
    t, d = input().split()
    t_list.append(t)
    d_list.append(d)


num_map = {}
for i in range(len(s)):
    if s[i] in num_map:
        num_map[s[i]].append(i)
    else:
        num_map[s[i]] = [i]

golem_list = [1 for i in range(n)]

for i in range(q):
    t = t_list[i]
    d = d_list[i]
    if t not in num_map:
        continue
    move_index = num_map[t]

    for j in move_index:
        if j == 0 and d == "L":
            golem_list[0] = 0
        elif j == n-1 and d == "R":
            golem_list[n-1] = 0
        elif d == "L":
            move_num = golem_list[j]
            golem_list[j-1] += move_num
            golem_list[j] = 0
        elif d == "R":
            move_num = golem_list[j]
            golem_list[j+1] += move_num
            golem_list[j] = 0


print(sum(golem_list))

