#通るかな？
def 解():
    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)

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