N, Q = map(int, input().split())
s = input()
t, q = [],[]
for i in range(Q):
  ti, qi = input().split()
  t.append(ti)
  q.append(qi)

g = [1] * N

for i in range(Q):
  n = s.count(t[i]) #sに含まれるtiの個数
  p = [] #tiで示されたマスのリスト
  s2 = s #解析用のs

  for j in range(n):
    p.append(s2.find(t[i]))
    s2 = s2[s2.find(t[i]):]
  for j in range(n): #pに示されたマスのゴーレムを移動
      if q[i] == "L" and g[p[j]] != 0:
        if p[n-j-1] > 0:
          g[p[n-j-1]-1] += g[p[n-j-1]]
          g[p[n-j-1]] = 0
        else:
          g[p[n-j-1]] = 0
      if q[i] == "R" and g[p[j]] != 0:
        if p[j] < N:
          g[p[j]+1] += g[p[j]]
          g[p[j]] = 0
        else:
          g[p[j]] = 0
#  print(i,g)
print(sum(g))
