from sys import stdin

input = stdin.readline

N, Q = list(map(int, input().split()))
s = input()

stage = {chr(i):[] for i in range(65, 65+26)}

for i in range(N):
    stage[s[i:i+1]].append(i)

golem = [1] * N

for i in range(Q):
    a, b = input().split()
    for n in stage[a]:
        if b == 'L' and golem[n] > 0:
            m = golem[n]
            golem[n] = 0
            if n > 0:
                golem[n-1] += m
        elif b == 'R' and golem[n] > 0:
            m = golem[n]
            golem[n] = 0
            if n < N-1:
                golem[n+1] += m

print(sum(golem))