N,Q=map(int,input().split())
S=input()

TD=[]
for i in range(Q):
    t, d = input().split()
    if d=='L':
        TD.append([t,-1])
    else:
        TD.append([t,1])

def check(place):
    for td in TD:
        if td[0]==S[place]:
            place+=td[1]
            if place<0:
                return -1
            elif place>=N:
                return 1
    return 0

l,r=-1,N
L,R=-1,N

while abs(r-l)>1:
    m=(l+r)//2
    if check(m)<0:
        l=m
    else:
        r=m
L=l
l,r=-1,N

while abs(r-l)>1:
    m=(l+r)//2
    if check(m)>0:
        r=m
    else:
        l=m

R=r

print(max(R-L-1,0))
