N, Q, S, *L = open(0).read().split()
N = int(N)
Q = int(Q)
l = -1
r = N
while l+1<r:
  s = (l+r)//2
  p = S[s]
  m = s
  for t,d in zip(*[iter(L)]*2):
    if p==t:
      if d=='L':
        m -= 1
      else:
        m += 1
    if m<=-1:
      l = s
      break
    if N<=m:
      r = s
      break
    p = S[m]
  else:
    r = s
ans = l+1
l = -1
r = N
while l+1<r:
  s = (l+r)//2
  p = S[s]
  m = s
  for t,d in zip(*[iter(L)]*2):
    if p==t:
      if d=='L':
        m -= 1
      else:
        m += 1
    if N<=m:
      r = s
      break
    if m<=-1:
      l = s
      break
    p = S[m]
  else:
    l = s

ans += N-r
print(N-ans)