A, B= map(int, input().split())
S = list(input())
C = [input().split() for _ in range(B)]

N = []
for i in range(A):
    N.append(1)

def golem(N, S, alpha, LR):
    indexes = [i for i, x in enumerate(S) if x == alpha]

    if LR == "L":
        for index in indexes:
            if index != 0:
                N[index-1] += N[index]
                N[index] = 0
            else:
                N[index] = 0
    else:
        for index in indexes:
            if index != A-1:
                N[index+1] = N[index]+ N[index+1]
                N[index] = 0
            else:
                N[index] = 0


for k in range(B):
    golem(N, S, alpha = C[k][0], LR = C[k][1])

print(sum(N))
