# -*- coding: utf-8 -*-
from collections import defaultdict
import copy

n, q = map(int, input().split())
s = input()

positions = defaultdict(set)
for i, c in enumerate(s):
    positions[c].add(i)
golems = [1]*n

for _ in range(q):
    target, direction = input().split()
    new_golems = copy.copy(golems)
    if direction == 'L':
        for i in positions[target]:
            if i == 0:
                new_golems[0] = 0
            elif golems[i] > 0:
                new_golems[i-1] = new_golems[i-1]+new_golems[i]
                new_golems[i] = 0
    else:
        for i in positions[target]:
            if i == n-1:
                new_golems[n-1] = 0
            elif golems[i] > 0:
                new_golems[i+1] = new_golems[i+1]+new_golems[i]
                new_golems[i] = 0
    golems = new_golems
print(sum(golems))