from collections import defaultdict

def testkilled(p,S,qry,N):
    pi=p
    c=S[pi]
    for q in qry:
        a,b=q
        if b=="R":
            d=1
        else:
            d=-1
        if c==a:
            pi+=d
            if pi==-1:
                return 1
            if pi==N:
                return 2
            c=S[pi]
    return 0

N,Q=[int(x) for x in input().split()]
S=input()
B=[1 for x in range(N)]
qry=[]
for q in range(Q):
    qry.append(input().split())
l=0
r=N
ans=N
while(r-l>1):
    p=(l+r)//2
    k=testkilled(p,S,qry,N)
    if k==1:
        l=p
    else:
        r=p
ans-= (p)

l=0
r=N
while(r-l>1):
    p=(l+r)//2
    k=testkilled(p,S,qry,N)
    if k==2:
        r=p
    else:
        l=p
ans-= (N-p-1)

print(ans)
#print(testkilled(0,S,qry,N))
#print(testkilled(1,S,qry,N))
#print(testkilled(2,S,qry,N))
