#!/usr/bin/env python
# -*- coding: utf-8 -*-


def left_trace(chars, moves, idx):
  if idx == len(chars) - 1:
    return idx

  for i, (t, d) in enumerate(moves):
    if t == chars[idx + 1] and d == 'L':
      ret = left_trace(chars, moves[i:], idx + 1)

      if ret is not None:
        return ret
    elif t == chars[idx] and d == 'R':
      return None

  return idx


def right_trace(chars, moves, idx):
  if idx == 0:
    return idx

  for i, (t, d) in enumerate(moves):
    if t == chars[idx - 1] and d == 'R':
      ret = right_trace(chars, moves[i:], idx - 1)

      if ret is not None:
        return ret
    elif t == chars[idx] and d == 'L':
      return None

  return idx


def main():
  _, Q = map(int, input().split())
  chars = input().strip()
  moves = [input().split() for _ in range(Q)]

  moves = moves[::-1]
  left = None
  right = None

  for i, (t, d) in enumerate(moves):
    if left is None and t == chars[0] and d == 'L':
      left = left_trace(chars, moves[i + 1:], 0)

    if right is None and t == chars[-1] and d == 'R':
      right = right_trace(chars, moves[i + 1:], len(chars) - 1)

    if left is not None and right is not None:
      break

  if left is None:
    left = -1

  if right is None:
    right = len(chars)

  print(max(right - left - 1, 0))


if __name__ == '__main__':
  main()

