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

gorem = [1]*N
for magic in A:
    for i in range(len(s)):
        if s[i] == magic[0]:
            if magic[1]=='L':
                if i == 0:
                    gorem[i] = 0
                else:
                    gorem[i-1]=gorem[i-1]+gorem[i]
                    gorem[i] = 0
            elif magic[1] == 'R':
                if i == N-1:
                    gorem[i] = 0
                else:
                    gorem[i+1] = gorem[i+1]+gorem[i]
                    gorem[i]=0
print(sum(gorem))