# -*- coding: utf-8 -*-
n, q = map(int, input().split())
s = input()

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

golem_pos = [1 for _ in range(n)]
for _ in range(q):
    t, d = input().split()

    step = 1 if d == 'L' else -1

    if t not in s_idx:
        continue

    for i in s_idx[t][::step]:
        if i == 0 and d == 'L':
            golem_pos[i] = 0
        elif i == n-1 and d == 'R':
            golem_pos[i] = 0
        elif d == 'L':
            golem_pos[i-1] += golem_pos[i]
            golem_pos[i] = 0
        else:
            golem_pos[i+1] += golem_pos[i]
            golem_pos[i] = 0

print(sum(golem_pos))
