argCntSpace,argCntSpell = map(int,input().split())

arySpace = list(input())
arySpaceBefore = [1] * argCntSpace
arySpaceAfter = [0] * argCntSpace

for i in range(argCntSpell):
  argSpell,argDirect = input().split()
  for j in range(argCntSpace):
    if argSpell == arySpace[j]:
      if argDirect == "R":
        nextJ = j + 1
      else:
        nextJ = j - 1
      if nextJ in range(argCntSpace):
        arySpaceAfter[nextJ] += arySpaceBefore[j]
      else:
        pass
    else:
      arySpaceAfter[j] += arySpaceBefore[j]

  arySpaceBefore = arySpaceAfter[:]
  arySpaceAfter = [0] * argCntSpace
  #print(arySpaceBefore)

print(sum(arySpaceBefore))