N,Q=map(int,input().split())
s=input()
commands=[input().split() for _ in range(Q)]

def move(i):
  k=i
  if k==-1 or k==N:
    return k
  for t,d in commands:
    if s[k]==t:
      if d=='R':
        k+=1
      else:
        k-=1
    if k==-1 or k==N:
      return k
  return k

#left search
low=0
high=N

##左にはみ出る一番右の位置→left
left=(low+high)//2

while(low<=high):
  vanish=False
  if move(left)==-1:
    vanish=True
  if low==high:
    if vanish:
      left=low
    else:
      left=low-1
    break
  if vanish:
    low=left+1
  else:
    high=left-1
  left=(low+high)//2

#右にはみ出る一番左の位置
low=0
high=N
right=(low+high)//2
while(low<=high):
  vanish=False
  if move(right)==N:
    vanish=True
  if low==high:
    if vanish:
      right=low
    else:
      right=low+1
    break
  if vanish:
    high=right-1
  else:
    low=right+1
  right=(low+high)//2
print(right-left-1)
'''
from collections import Counter

N,Q=map(int,input().split())
s=input()
moji={}
for i in range(Q):
  t,d=input().split()
  moji.setdefault(t,[0,0,0])
  if d=='L':
    moji[t][0]-=1
  else:
    moji[t][0]+=1
  #rightmax
  if moji[t][0]>moji[t][1]:
    moji[t][1]=moji[t][0]
  #leftmax
  if moji[t][0]<moji[t][2]:
    moji[t][2]=moji[t][0]

answer=0
for i in range(N):
  key=s[i]
  if moji[s[i]][1]+i>N-1 or i+moji[s[i]][2]<0:
    answer+=1
print(moji)
print(answer)
'''
