N, Q =map(int,input().split())
s = list(input())
A = [input().split() for _ in range(Q)]

g = [] #各マスのゴーレムの数
for i in range(0, N):
    g.append(1)

for a in range(0, Q):
    b = [i for i, x in enumerate(s) if x == A[a][0]] #sの中で呪文で唱えた文字と一緒のものを取り出す
    for i in range(0, len(b)):
        if A[a][1] == "L":
            if b[i] == 0:
                g[b[i]] = 0
            else:
                g[b[i]-1] = g[b[i]-1] + g[b[i]]
                g[b[i]] = 0
        else:
            if b[i] == N-1:
                g[b[i]] = 0
            else:
                g[b[i]+1] =  g[b[i]+1] + g[b[i]]
                g[b[i]] = 0

sum = 0
for i in range(0, N):
    sum += g[i]

print(sum)