N, Q = map(int, input().split())
s = input()

al = [chr(i) for i in range(65,65+26)]

D = {a:[i+1 for i in range(N) if s[i] == a] for a in al}

L = [1] * (N+2)

for q in range(Q):
    t, d = input().split()
    if d == 'L':
        for i in D[t]:
            L[i-1] += L[i]
            L[i] = 0
    else:
        for i in D[t][::-1]:
            L[i+1] += L[i]
            L[i] = 0

print(sum(L[1:-1]))
