
#通るかな？
def 解():
    import numpy as np
    import sys
    input = sys.stdin.readline

    N,Q = [int(_) for _ in input().split()]

    S = input()
    dS = {}
    for i in range(1,N+1):
        s = S[i-1]
        if s in dS:
            dS[s].add(i)
        else:
            dS[s]={i}
    #aM = [1]*(N+2)
    #aM = {i:1 for i in range(N+2)}
    aM = np.array([1]*(N+2))

    for _ in range(Q):
        t,d = input().split()
        if t in dS:
            if d == "R":
                for i in dS[t]:
                    if aM[i]:
                        aM[i+1] += aM[i]
                        aM[i] = 0
            else:
                for i in dS[t]:
                    if aM[i]:
                        aM[i-1] += aM[i]
                        aM[i] = 0

    #print(sum(aM[i] for i in range(1,N+1)))
    print(sum(aM[1:N+1]))
解()
