# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, Q = ds_in()
S = s_in()
strings = set(S)
s2d = {}
for i, s in enumerate(strings):
    s2d[s] = i

# 0要素は次に死にそうな位置
death = {s: [[0, 0], [-1]] for s in strings}
# right_death = {s: [[0, 0], []] for s in strings}
for i, s in enumerate(S):
    death[s][1].append(i)
    # right_death[s][1].append(i)

for s in strings:
    death[s][0][1] = len(death[s][1]) - 2
    death[s][1].append(N)

move_list = []
for _ in range(Q):
    t, d = s_in().split()
    move_list.append([t, d])

flag = False
for move in move_list[::-1]:
    t, d = move
    # print(t, d)
    # print(death)
    if t not in strings:
        continue
    if d == 'L':
        if death[t][0][0] < len(death[t][1])-2:
            cur = death[t][1][death[t][0][0] + 1]  # current leftest place of t
            if cur > 0:
                left_char = S[cur-1]
                if death[left_char][1][death[left_char][0][0] + 1] > cur-1:
                    death[t][0][0] += 1
            else:
                death[t][0][0] += 1
    else:
        if death[t][0][1] > -1:
            cur = death[t][1][death[t][0][1] + 1]
            if cur < N-1:
                right_char = S[cur+1]
                if death[right_char][1][death[right_char][0][1] + 1] < cur+1:
                    death[t][0][1] -= 1
            else:
                death[t][0][1] -= 1

count = 0
for s in strings:
    count = count + max(0, death[s][0][1] - (death[s][0][0] - 1))

print(count)
