N, Q = map(int, input().split())
s = input()
A = [1] * (N + 2)

for i in range(Q):
    t, d = input().split()
    for i, x in enumerate(s):
        if t == x:
            if d == 'L':
                A[i] += A[i + 1]
                A[i + 1] = 0
            else:
                A[i + 2] += A[i + 1]
                A[i + 1] = 0
                
print(sum(A[1 : -1]))