import time

if __name__ == '__main__':
    start = time.time()


    A, B= map(int, input().split())
    S = list(input())
    C = [input().split() for _ in range(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 range(B):
        golem(N, S, alpha = C[k][0], LR = C[k][1])

    print(sum(N))
    elapsed_time = time.time() - start
    # print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
