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


def main():
  _, Q = map(int, input().split())
  chars = [int(v) - 65 for v in input().strip().encode(encoding='utf-8')]
  nums = [1] * len(chars)
  indices = [[] for _ in range(26)]

  for i, c in enumerate(chars):
    indices[c].append(i)

  for _ in range(Q):
    c, d = input().split()
    c = int(c.encode(encoding='utf-8')[0]) - 65
    d = -1 if d == 'L' else 1
    srcs = indices[c]
    dsts = [s + d for s in srcs]

    for s, d in zip(srcs, dsts):
      n = nums[s]
      nums[s] = 0

      if 0 <= d < len(nums):
        nums[d] += n

  print(sum(nums))


if __name__ == '__main__':
  main()

