import copy
N,Q = map(int,input().split())
S = input()
spell = [list(input().split()) for i in range(Q)]
list = [1]*(N+2)

for t,d in spell:
    list_pre = copy.copy(list)
    list[0] = 0
    list[-1] = 0
    for i in range(N):
        if S[i] == t and list_pre[i+1] > 0:
            if d == 'L':
                list[i] += list[i+1]
                list[i+1] = 0
            else:
                list[i+2] += list[i+1]
                list[i+1] = 0

print(sum(list[1:N+1]))