import sys
input = sys.stdin.readline
import bisect
sys.setrecursionlimit(10**8)

N,Q=map(int,input().split())
S=input().strip()
M=[input().split() for i in range(Q)]

#逆からシミューレション

PLACE=0
flag=0

for now in range(Q-1,-1,-1):
    if M[now][0]==S[PLACE] and M[now][1]=="L":
        PLACE+=1

PLACE2=N-1

for now in range(Q-1,-1,-1):
    if M[now][0]==S[PLACE2] and M[now][1]=="R":
        PLACE2-=1


if PLACE-1>PLACE2+1:
    print(N)
else:
    print(N-(PLACE+(N-1-PLACE2)))