N, Q = list(map(int, input().split()))
s = input()
t, d = [0]*Q, [0]*Q
num_Gorem = [1]*N
for i in range(Q):
    t[i], d[i] = input().split()
    target = t[i]
    index = -1
    while True:
        index = s.find(target, index + 1)
        if index == -1:
            break
        if num_Gorem[index] == 0:
            continue
        if d[i] == 'L':
            if index>0:
                num_Gorem[index-1] = num_Gorem[index-1] + num_Gorem[index]
            num_Gorem[index] = 0
        if d[i] == 'R':
            if index < N-1:
                num_Gorem[index+1] = num_Gorem[index+1] + num_Gorem[index]
            num_Gorem[index] = 0

print(sum(num_Gorem))
