import numpy as np


n, q = map(int, input().split())
s = input()
pair = [input().split() for _ in range(q)]
# 場所
lst = list(set(s))
# 初期位置(0スタート)
place = dict([(l, []) for l in lst])
for i, j in enumerate(s):
    place[j].append(i)
for l in lst:
    place[l] = np.array(place[l])
# print(init)
# 座標
grid = np.ones(n, np.int)
# 移動
rang = dict([(l, [0, 0]) for l in lst])
for i, j in pair:
    if not(i in lst):
        continue
    index = place[i]
    tmp = grid[index]
    grid[index] = 0
    if j == 'L':
        new_index = index[1:] if index[0] == 0 else index
        new_tmp = tmp[1:] if index[0] == 0 else tmp
        grid[new_index - 1] += new_tmp
    else:
        new_index = index[:-1] if index[-1] == n - 1 else index
        new_tmp = tmp[:-1] if index[-1] == n - 1 else tmp
        grid[new_index + 1] += new_tmp
# 処理
print(np.sum(grid))