# coding: utf-8
import sys
import numpy as np

input = sys.stdin.readline

N, Q = map(int, input().split())
S = input().strip()
td_list = [input().split() for _ in range(Q)]
dest = [-2] * (N+1)

def sim(i): # i番目のゴーレムの最終結果を得る
  idx = i
  if dest[i] != -2:
    return dest[i]
  for td in td_list:
    if idx == -1:
      dest[i] = -1
      return -1
    elif idx == N:
      dest[i] = N
      return N
    elif td[0] == S[idx]:
      if td[1] == "L":
        idx -= 1
      else:
        idx += 1
  dest[i] = idx
  return idx


# 左側の境界を探索
idx = N // 2
lb = 0

while True:
  if idx == N-1: # すべて左に出た
    lb = N-1
    break
  l = sim(idx)
  r = sim(idx+1)
  if l == -1 and r != -1: # 境界がみつかった
    lb = idx
    break
  if l == -1:
    idx = (idx + N) // 2
  else:
    idx = idx // 2

# 右側の境界を探索
idx = N // 2
rb = 0

while True:
  if idx == 0: # すべて右に出た
    rb = 0
    break
  l = sim(idx)
  r = sim(idx+1)
  if l != N and r == N: # 境界が見つかった
    rb = idx
    break
  if l != N:
    idx = (idx + N) // 2 
  else:
    idx = idx // 2

print(rb - lb)
