n,q = map(int, input().split())
s = input()
td=[list(map(str,input().split())) for i in range(q)]

def solve(ind):
    for tmp in td:
        if tmp[0] == s[ind]:
            if tmp[1]=="R":
                ind+=1
            else:
                ind-=1
            if ind < 0: # fall left
                return -1
            if len(s) <= ind : # fall right
                return 1
    return 0 # dont fall

l=0
r=len(s)
while r-l>1:
    mid=(l+r)//2

    if solve(mid)>=0:
        r=mid
    else:
        l=mid
ans=r

l=0
r=len(s)
while r-l>1:
    mid=(l+r)//2

    if solve(mid)<=0:
        l=mid
    else:
        r=mid
ans+=(len(s)-r)
print(n-ans)