N,Q = (int(x) for x in input().split())
s = input()
T = []
D = []

g = [1] * N

for i in range(Q):
    t,d = (x for x in input().split())
    #T.append(t)
    #D.append(d)
    
    if d == "L":
        for i in range(N):
            if s[i] == t:
                if i>0:
                    g[i-1] += g[i]
                g[i] = 0
    else:
        for i in range(N-1,-1,-1):
            if s[i] == t:
                if i<N-1:
                    g[i+1] += g[i]
                g[i] = 0
    #print(g)
                
print(sum(g))
    



