N,Q=map(int,input().split())
s=input()
T=[]
D=[]
for i in range(Q):
  t,d=input().split()
  T.append(t)
  D.append(d)

def check_end(n):
  position = n
  for i in range(Q):
    if T[i]==s[position]:
      if D[i]=='L':
        position -= 1
      else:
        position += 1
    if position<0 or position>=N:
      break
  #print("end"+str(n)+" "+str(position))
  return position


left=0
right=N-1
left_end=check_end(left)
right_end=check_end(right)
#print(str(left_end)+" "+str(right_end))

if left_end==right_end==-1 or left_end==right_end==N:
  print(0)
  exit()
elif left_end==right_end==0:
  print(N)
  exit()

slip_left=slip_right=0
diff=N-1
if left_end==-1:
  while diff>1:
    new=int((left+right)/2)
    new_end=check_end(new)
    if new_end==-1:
      left=new
    else:
      right=new
    diff=right-left
  slip_left=left+1
  #print('slip_left'+str(slip_left))
  
diff=N-1
left=0
right=N-1
if right_end==N:
  while diff>1:
    new=int((left+right)/2)
    new_end=check_end(new)
    if new_end==N:
      right=new
    else:
      left=new
    diff=right-left
  slip_right=N-right
  #print('slip_right'+str(slip_right))

#print(str(slip_left)+" "+str(slip_right))
print(N-slip_left-slip_right)