# coding: utf-8
# Your code here!

i = input().split()

n = int(i[0])
q = int(i[1])

i = input().split()

mass = list(i[0])
# print(mass)
golem_num_list = [1] * len(mass)

# print(n, q)

# 呪文回数
for i in range(q):
    a = input().split()
    mass_char = a[0]
    move = a[1]
    
    for j in range(len(mass)):
        if mass_char == mass[j]:
            
            # print("一致 {} {}".format(mass_char, move))
            if move == 'L':
                if j != 0:
                    golem_num_list[j - 1] += golem_num_list[j]
                    golem_num_list[j] = 0
                else:
                    golem_num_list[j] = 0
            elif move == 'R':
                if j != len(mass) - 1:
                    golem_num_list[j + 1] += golem_num_list[j]
                    golem_num_list[j] = 0
                else:
                    golem_num_list[j] = 0
            # print(golem_num_list)

sum = 0
for item in range(len(golem_num_list)):
    sum += int(golem_num_list[item])
    
print(sum)

