import sys
input=sys.stdin.readline
N,Q=map(int,input().split())
s=["s"]+list(input())+["e"]

A=[]

for i in range(Q):
    t,d=list(input().split())
    A.append([t,d])
#print(A)

High=N
Low=1

while abs(High - Low)>2:
    Mid=(High + Low)//2
    #print(H,Mid,L)
    P=Mid
    T=s[P]
    for i in range(Q):
        if A[i][0]==T:
            if A[i][1]=="L":
                P-=1
                T=s[P]
            else:
                P+=1
                T=s[P]
    if P==0:
        Low=Mid
    else:
        High=Mid
for j in range(min(5,N)):
    Mid= High-j
    if Mid==0:
        left=0
    P=Mid
    T=s[P]
    for i in range(Q):
        if A[i][0]==T:
            if A[i][1]=="L":
                P-=1
                T=s[P]
            else:
                P+=1
                T=s[P]
    if P==0:
        left=Mid+1
        break
#print(left)        

High=N
Low=1

while abs(High - Low)>2:
    Mid=(High + Low)//2
    #print(H,Mid,L)
    P=Mid
    T=s[P]
    for i in range(Q):
        if A[i][0]==T:
            if A[i][1]=="L":
                P-=1
                T=s[P]
            else:
                P+=1
                T=s[P]
    if P==N:
        High=Mid
    else:
        Low=Mid
for j in range(min(5,N)):
    Mid= Low+j
    if Mid==N:
        right=N
    P=Mid
    T=s[P]
    for i in range(Q):
        if A[i][0]==T:
            if A[i][1]=="L":
                P-=1
                T=s[P]
            else:
                P+=1
                T=s[P]
    if P==N+1:
        right=Mid-1
        break
#print(right)        
print(max(0,right-left+1))

        