N,Q=map(int,input().split())
S=input()
TD=[tuple(input().split()) for _ in range(Q)]

def go(x):
    pos=x
    for t,d in TD:
        if pos==N: return N
        if pos==-1: return -1
        if t==S[pos]:
            if d=='L': pos-=1
            else: pos+=1
    return pos

U=N
L=-1
while U-L>1:
    x=(U+L)//2
    if go(x)==-1: L=x
    else: U=x
left=L

U=N
L=-1
while U-L>1:
    x=(U+L)//2
    if go(x)==N: U=x
    else: L=x
right=U

print(right-left-1)