N,Q=map(int,input().split())
S=input()+' '
TD=[input().split() for _ in [0]*Q]
def ith_move(i):
    k=i
    for t,d in TD:
        if S[k]==t:
            k+=1 if d=='R' else -1
        if k==-1 or k==N:return k
    return k
#print([(i,ith_move(i)) for i in range(N)])

low=0; high=N; L=(high+low)//2 #左に落ちる一番右を探索
while low<=high:
    fall = ith_move(L)==-1
    #print(f"L [{low}, {high}); {L}:{fall}")
    if low==high: L = high if fall else high-1; break
    if fall: low = L+1
    else: high = L-1
    L = (high+low)//2

low=0; high=N; R=(high+low)//2 #右に落ちない一番右を探索
while low<=high:
    fall = ith_move(R)==N
    #print(f"R [{low}, {high}); {R}:{fall}")
    if low==high: R = high-1 if fall else high; break
    if fall: high = R-1
    else: low = R+1
    R = (high+low)//2

#print(L,R)
print(R-L)