n,q=map(int, input().split())
s=input()
g_list=[1 for i in range(n)]
for i in range(q):
    t,d=input().split()
    for j in range(n):
        if s[j]==t:
            tmp=g_list[j]
            g_list[j]=0
            if d=="R":
                if j+1<n:
                    g_list[j+1]+=tmp
            if d=="L":
                if j-1 >= 0:
                    g_list[j-1]+=tmp
sum=0
for i in g_list:
    sum+=i
print(sum)
                