n,q = map(int, input().split())
s = "#" + input() + "#"
l = [tuple(input().split()) for _ in range(q)]
d = {"L":-1, "R":1}
def move(x):
  for i in l:
    if i[0] == s[x]:
      x += d[i[1]]
    if x in [0,n+1]:
      break
  return x
def isr(x):
  if move(x) == n+1:
    return True
  else:
    return False
def isl(x):
  if move(x) == 0:
    return True
  else:
    return False
hi1,hi2 = n+1,n+1
lo1,lo2 = 0,0
while hi1-lo1>1:
  mid1 = (hi1+lo1)//2
  if isr(mid1):
    hi1 = mid1
  else:
    lo1 = mid1
while hi2-lo2>1:
  mid2 = (hi2+lo2)//2
  if isl(mid2):
    lo2 = mid2
  else:
    hi2 = mid2
print(max(hi1-lo2-1,0))