import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
S = '-' + sr() + '-'
TD = [sr().split() for _ in range(Q)]
def check(i, goal):
    if i == goal:
        return True
    for t, d in TD[::-1]:
        if d == 'L':
            if goal <= N and S[goal+1] == t:
                goal += 1
                if goal == i:
                    return True
        else:
            if goal >= 1 and S[goal-1] == t:
                goal -= 1
                if goal == i:
                    return True
    return False

left = 0 # OK
right = N+1
while right > left + 1:
    mid = (left + right) // 2
    if check(mid, 0):
        left = mid
    else:
        right = mid

go_to_left = left

left = 0
right = N+1 # OK
while right > left + 1:
    mid = (left + right) // 2
    if check(mid, N+1):
        right = mid
    else:
        left = mid

go_to_right = N + 1 - right

answer = max(0, N - (go_to_left + go_to_right))
print(answer)
# 49
