N,Q=map(int,input().split())
s=input()

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

def isAlive(pos):
  for t,d in tdlist:
    if t == s[pos]:
      if d == 'L':
        pos -= 1
        if pos == -1:
          return -1
      elif d == 'R':
        pos += 1
        if pos == N:
          return 1
        
  return 0

#res_list = []
#for i in range(N):
#  res_list.append(isAlive(i))
#print(res_list)

max_L = -1
if isAlive(0) == -1:
  intv_L = [0, N-1]
  while (True):
    if intv_L[1]-intv_L[0] < 10:
      break
      
    center = (intv_L[0]+intv_L[1])//2    
    if isAlive(center) == -1:
      intv_L = [center, intv_L[1]]
    else:
      intv_L = [intv_L[0], center]

  for i in range(intv_L[0],intv_L[1]+1):
    if isAlive(i) == 0:
      max_L = i-1
      break

min_R = N
if isAlive(N-1) == 1:
  intv_R = [0, N-1]
  while (True):
    if intv_R[1]-intv_R[0] < 10:
      break
      
    center = (intv_R[0]+intv_R[1])//2    
    if isAlive(center) == 1:
      intv_R = [intv_R[0], center]
    else:
      intv_R = [center, intv_R[1]]

  for i in range(intv_R[0],intv_R[1]+1):
    if isAlive(i) == 1:
      min_R = i
      break

#print((max_L,min_R))
print(-max_L+min_R-1)