N, Q = list(map(int, input().split()))
S = input()
spell = [list(input().split()) for i in range(Q)]

l, r = 0, N-1
for t, d in spell:
    if S[l] == t and d == 'L':
        l += 1
    elif 0 < l and S[l - 1] == t and d == 'R':
        l -= 1
    if S[r] == t and d == 'R':
        r -= 1
    elif r < N - 1 and S[r + 1] == t and d == 'L':
        r += 1

print(max(r - l + 1, 0))
