import sys

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)]

L = 0
limit_to_L = 0
for t, d in TD[::-1]:
    if d == 'L':
        if L <= N and S[L+1] == t:
            L += 1
            if L > limit_to_L:
                limit_to_L = L
    if d == 'R':
        if L >= 1 and S[L-1] == t:
            L -= 1
R = N+1
limit_to_R = N+1
for t, d in TD[::-1]:
    if d == 'L':
        if R <= N and S[R+1] == t:
            R += 1
    if d == 'R':
        if R >= 1 and S[R-1] == t:
            R -= 1
            if R < limit_to_R:
                limit_to_R = R

answer = max(0, limit_to_R - limit_to_L - 1)
print(answer)
# 34