n, q = map(int, input().split())
s = input()
L = [1 for i in range(n)] #カウント用
x = [list(input().split()) for i in range(q)]


for i in range(q):#呪文ループ
  for j in range(n):#マスループ　左から
    if x[i][0] == s[j]:
      if x[i][1]=='L':

        if j-1>=0:
          L[j-1] +=L[j]
          L[j] = 0
        else:
          L[j] = 0

      elif x[i][1]=='R':

        if (j+1)<=(n-1):
          L[j+1] +=L[j]
          L[j] = 0
        else:
          L[j] = 0

sum = 0
for i in range(n):
  sum += L[i]

print(sum)