n,q = map(int, input().split())
s = "#" + input() + "#"
l = [tuple(input().split()) for _ in range(q)]
def move(x,g):
  for i in l:
    if i[0] == s[x]:
      x += (i[1]=="R") or -1
  return x==g
hi1 = n+1
lo1,lo2 = 0,0
while hi1-lo1>1:
  mid1 = (hi1+lo1)//2
  if move(mid1,n+1):
    hi1 = mid1
  else:
    lo1 = mid1
hi2 = hi1
while hi2-lo2>1:
  mid2 = (hi2+lo2)//2
  if move(mid2,0):
    lo2 = mid2
  else:
    hi2 = mid2
print(hi1-lo2-1)