

ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

N,Q = map(int,input().split())
S = input()
MassMoji = []
MassG = [1]*N

for i in range(len(ABC)):
    MassMoji.append([j for j, x in enumerate(S) if x == ABC[i]])

for i in range(Q):
    l,r = map(str,input().split())
    for j in MassMoji[ABC.index(l)]:
        if r == 'L':
            if j == 0:
                MassG[j] = 0
            else:
                MassG[j-1] += MassG[j]
                MassG[j] = 0
        if r == 'R':
            if j == N-1:
                MassG[j] = 0
            else:
                MassG[j+1] += MassG[j]
                MassG[j] = 0

print(sum(MassG))