import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input().rstrip()
td = [list(input().rstrip().split()) for i in range(q)]
def judge(x,direction):
  if direction == "L":
    if x == n:
      return True
    if x == -1:
      return False
    jedge = lambda w: True if w>=0 else False
  else:
    if x == -1:
      return True
    if x == n:
      return False
    jedge = lambda w: True if w<n else False
  for i in range(q):
    if td[i][0] == s[x]:
      if td[i][1] == "R":
        x += 1
      else:
        x -= 1
    if jedge(x) == False:
      return False
  return True
l = -1
r = n
while l+1<r:
  x = (l+r)//2
  if judge(x,"L"):
    r = x
  else:
    l = x
ansl = r
l = -1
r = n
while l+1<r:
  x = (l+r)//2
  if judge(x,"R"):
    l = x
  else:
    r = x
ansr = l
print(max(0,ansr-ansl+1))
