N, Q = map(lambda x: int(x), input().split(" "))
S = input()
counts = [1] * N
for i in range(Q):
    t, d = input().split(" ")
    if d == "R":
        for j in range(N-1):
            if S[j] == t:
                counts[j+1] += counts[j]
                counts[j] = 0
        if S[N-1] == t:
            counts[N-1] = 0
    else:
        if S[0] == t:
            counts[0] = 0
        for j in range(1, N):
            if S[j] == t:
                counts[j-1] += counts[j]
                counts[j] = 0
print(sum(counts))