# -*- coding: utf-8 -*-

from sys import stdin

def load():
    n = stdin.readline()
    return n

n,q = [ int(x) for x in load().split(' ')]
n = int(n)

index = {}
for i,x in enumerate(load()):
    if x not in index:
        index[x] = [i]
    else:
        index[x].append(i)

golem = [1 for n in range(n)]

for loop in range(q):
    t,d = load().split()
    isLeft = 'L' == d

    if t not in index:
        continue

    for target in index[t]:
        if isLeft and target > 0:
            golem[target-1] += golem[target]
        elif not isLeft and target < n - 1:
            golem[target+1] += golem[target]
        golem[target] = 0

print(sum(golem))