n,q=map(int,input().split())
s=list(input())
l=[]
for i in range(q):
    l.append(list(input().split()))
f=s[0]
b=s[n-1]
flg=0
p=0
fpmax=0
for i in reversed(l):
    if flg==0 and i[0]==f and i[1]=="L":
        flg=1
        p=1
    elif flg==1: 
        if i[0]==s[p] and i[1]=="L":
            p+=1
        elif p!=1:
            if i[0]==s[p-2] and i[1]=="R":
                p-=1
    
    if p>fpmax:
        fpmax=p
flg=0
p=0
bpmax=0
s.reverse()
for i in reversed(l):
    if flg==0 and i[0]==b and i[1]=="R":
        flg=1
        p=1
    elif flg==1: 
        if i[0]==s[p] and i[1]=="R":
            p+=1
        elif p!=1:
            if i[0]==s[p-2] and i[1]=="L":
                p-=1
    if p>bpmax:
        bpmax=p
ans=n-fpmax-bpmax
if ans<0:
    ans=0
print(ans)