n,q = map(int,input().split())
s = list(input())
g = [1]*n
for i in range(q):
    x,y = input().split()
    if y=="R": y=1
    else: y=-1
    for j in range(n):
        if s[j]==x and g[j]>0:
            if 0<=j+y<n:
                g[j+y] += g[j]
            g[j]=0
print(sum(g))