
import numpy as np
A, B= map(int, input().split())
S = list(input())
C = [input().split() for _ in xrange(B)]

N = [1] * A

def golem(N, S, alpha, LR):
    indexes = [i for i, x in enumerate(S) if x == alpha]
    if len(indexes) > 0:
        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 xrange(B):
    golem(N, S, alpha = C[k][0], LR = C[k][1])

print(np.sum(N))
