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:
    change = [i for i, x in enumerate(s) if x == magic[0]]
    #print(change)
    for i in change:
        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(gorem)
print(sum(gorem))