input_lines = input().split()
N = int(input_lines[0])
Q = int(input_lines[1])
s = input()
t = []
d = []
for i in range(Q):
    input_lines = input().split()
    t.append(input_lines[0])
    d.append(input_lines[1])
posi_golem = [1] * N
num_golem = N
for i in range(Q):
    for j in range(N):
        if s[j] == t[i]:
            if d[i] == 'L':
                if j > 0:
                    posi_golem[j-1] += posi_golem[j]
                posi_golem[j] = 0
            elif d[i] == 'R':
                if j < N-1:
                    posi_golem[j+1] += posi_golem[j]
                posi_golem[j] = 0
print(sum(posi_golem))
