N, Q = map(int, input().split())
s = input()

golems = [1 for _ in range(N)]

index_table = {}
for i, c in enumerate(s):
    if c in index_table:
        index_table[c].append(i)
    else:
        index_table[c] = [i]

for i in range(Q):
    t_i, d_i = input().split()
    if t_i not in index_table:
        continue
    indexes = index_table[t_i]
    if indexes is not None and len(indexes) > 0:
        for index in indexes:
            golem_num = golems[index]
            golems[index] = 0
            if d_i == 'L' and index != 0:
                golems[index - 1] += golem_num
            elif d_i == 'R' and index != N - 1:
                golems[index + 1] += golem_num

count = 0
for i, g in enumerate(golems):
    count += g

print(count)