str_N, str_Q = input().split()
N = int(str_N)
Q = int(str_Q)
S = input()
s = '-' + S + '--'

t = ['-']
d = ['-']
for i in range(Q):
    t_i, d_i = input().split()
    t.append(t_i)
    d.append(d_i)

def g(i, n):
    if n < 0 or n > N + 1:
        return 0
    elif i == 0:
        if n == 0 or n == N + 1:
            return 0
        else:
            return 1
    else:
        a = g(i-1, n-1) * (1 if t[i] == s[n-1] and d[i] == 'R' else 0) \
            + g(i-1, n) * (1 if t[i] != s[n] else 0) \
            + g(i-1, n+1) * (1 if t[i] == s[n+1] and d[i] == 'L' else 0)
        return a

print(N - g(Q, 0) - g(Q, N+1))