n,q = map(int,input().split())
word = input()
xy= [tuple(input().split()) for i in range(q)]

# 右探索
low = 0
high = n - 1
pos = (low + high) // 2
while low <= high:
  flag = 0
  for x, y in xy:
    if (y == 'L') and (x == word[pos]):
      pos -= 1
    elif (y == 'R') and (x == word[pos]):
      pos += 1
    if (pos == n):
      flag = 1
      break
    elif (pos == -1):
      break
  if (flag == 1):
    high = ((low + high) // 2) - 1
  else:
    low = ((low + high) // 2) + 1
  pos = (low + high) // 2
right_pos = pos
# 左探索
low = 0
high = n - 1
pos = (low + high) // 2
while low <= high:
  for x, y in xy:
    flag = 0
    if (y == 'L') and (x == word[pos]):
      pos -= 1
    elif (y == 'R') and (x == word[pos]):
      pos += 1
    if (pos == -1):
      flag = 1
      break
    elif (pos == n):
      break
  if (flag == 0):
    high = ((low + high) // 2) - 1
  else:
    low = ((low + high) // 2) + 1
  pos = (low + high) // 2
left_pos = pos
print(right_pos - left_pos)