def main():
    N, Q = input().split()
    N = int(N)
    Q = int(Q)
    if N > Q:
        R = Q
    else:
        R = N
    G = [1] * N
    S = input()
    for _ in range(Q):
        t, d = input().split()
        if d == "L":
            # for i in range(0,N):
            for i in range(0,R):
                if S[i] == t and G[i] > 0:
                    if i == 0:
                        G[i] = 0
                    else:
                        G[i-1] = G[i-1] + G[i]
                        G[i] = 0

        else: # "R"
            # for i in range(N-1,-1,-1):
            for i in range(N-1,N-R-1,-1):
                if S[i] == t and G[i] > 0:
                    if i == N-1:
                        G[i] = 0
                    else:
                        G[i+1] = G[i+1] + G[i]
                        G[i] = 0
        #print(G)
    print(sum(G))

if __name__ == '__main__':
    main()
