n, q = map(int, input().split())
S = list(input())
dic_S = {}
for i in range(n):
    s = S[i]
    if s not in dic_S:
        dic_S[s] = [i]
    else:
        dic_S[s].append(i)

for i in range(q):
    t, d = input().split()
    if t in dic_S:
        L = dic_S[t][:]
        dic_S[t] = []
        l = len(L)
        for j in range(l):
            x = L[j]
            if d == "R":
                x += 1
                if x >= n:
                    continue
            else:
                x -= 1
                if x < 0:
                    continue
            dic_S[S[x]].append(x)

cou = 0
for s in dic_S:
    L = dic_S[s][:]
    l = len(L)
    cou += l

print(cou)