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

def fall_d(i):
  now = i
  for t, d in td:
    if s[now] == t:
      if d == 'L':
        now -= 1
      else:
        now += 1
    if now == 0:
      return 'Left'
    elif now == n + 1:
      return 'Right'
  return 'Remain'

ll, lr = 0, n + 1
while ll != lr:
  mid = (ll + lr) // 2
  if fall_d(mid) == 'Left':
    ll = mid + 1
  else:
    lr = mid

rl, rr = 0, n + 1
while rl != rr:
  mid = (rl + rr) // 2
  if fall_d(mid) == 'Right':
    rr = mid
  else:
    rl = mid + 1

print(rr - ll)
