n, q = map(int, input().split())
s = input().strip()
td = [tuple(input().strip().split()) for _ in range(q)]

def is_fall_l(i):
  now = i
  for t, d in td:
    if s[now] == t:
      if d == 'L':
        now -= 1
      else:
        now += 1
    if now == -1:
      return True
  return False

def is_fall_r(i):
  now = i
  for t, d in td:
    if s[now] == t:
      if d == 'L':
        now -= 1
      else:
        now += 1
    if now == n:
      return True
  return False

ll, lr = 0, n-1
while ll != lr:
  mid = (ll + lr) // 2
  if is_fall_l(mid):
    ll = mid + 1
  else:
    lr = mid

rl, rr = 0, n-1
while rl != rr:
  mid = (rl + rr) // 2
  if is_fall_r(mid):
    rr = mid
  else:
    rl = mid + 1

if rl == n-1:
  rl += 1
if lr == 0:
  lr -= 1

print(rl - lr)
