N,Q = map(int,input().split())
s = input()
t = [0]*Q
d = [0]*Q

for i in range(Q):
    t_,d_ = input().split()
    t[i] = t_
    d[i] = d_

num = [1]*N

for i in range(Q):
    for j in range(N):
        if s[j]==t[i]:
            if d[i]=='R':
                if j < N-1:
                    num[j+1] += num[j]
                num[j]=0
            else:
                if j > 0:
                    num[j-1] += num[j]
                num[j]=0

print(sum(num))
                