import math
N, Q = [int(_) for _ in input().split()]
S = '..' + input() + '..'  # len(S)==N+4
TD = [input().split() for _ in range(Q)]

maxl = l = 1
minr = r = N + 2

for t, d in TD[::-1]:
    if d == 'L':
        if t == S[l + 1]:
            l += 1
        if t == S[r + 1]:
            r += 1
    else:
        if t == S[l - 1]:
            l -= 1
        if t == S[r - 1]:
            r -= 1
    maxl = max([maxl, l])
    minr = min([minr, r])
print(minr - maxl - 1)
