N,Q=map(int,input().split())
s=["x"]+list(input())+["x"]
#print(s)
L=[]
for i in range(Q):
    t=list(input().split())
    L.append(t)
#print(L)
h=N
l=1

while abs(h-l)>2:
    Mid=(h+l)//2
    P=Mid
    for i in range(Q):
        if s[P]==L[i][0]:
            if L[i][1]=="L":
                P-=1
            else:
                P+=1
                
    if P==0:
        l=Mid
    else:
        h=Mid
#print(l,h)
for j in range(4):
    M=l-1+j
    P=M
    for i in range(Q):
        if s[P]==L[i][0]:
            #print("S",j,P,i)
            if L[i][1]=="R":
                P+=1
            else:
                P-=1
    #print("A",M,P)
    if P!=0:
        LEFT=l-1+j
        break

h=N
l=1

while abs(h-l)>2:
    Mid=(h+l)//2
    P=Mid
    for i in range(Q):
        if s[P]==L[i][0]:
            if L[i][1]=="L":
                P-=1
            else:
                P+=1
                
    if P==N+1:
        h=Mid
    else:
        l=Mid
for j in range(4):
    M=h+1-j
    P=M
    for i in range(Q):
        if s[P]==L[i][0]:
            if L[i][1]=="L":
                P-=1
            else:
                P+=1
    if P!=N+1:
        RIGHT=h+1-j
        break
        
print(max(0,RIGHT - LEFT +1))
#print(RIGHT,LEFT)