import sys
readline = sys.stdin.readline
N, Q = map(int, readline().split())
S = readline()
C = [readline().strip().split() for i in range(Q)]
C.reverse()
l = -1; r = N
for t, d in C:
    if d == 'L':
        if l+1 < N and S[l+1] == t:
            l += 1
        if r < N and S[r] == t:
            r += 1
    else:
        if r-1 >= 0 and S[r-1] == t:
            r -= 1
        if l >= 0 and S[l] == t:
            l -= 1
print(r-l-1)