N, Q = list(map(int, input().split()))
s = input()

lst = []
for i in range(Q):
  data = list(input().split())
  lst.append(data)
  
MAP = []
for i in range(N+2):
  if i == 0:
    data = ["", ""]
  elif i == N+1:
    data = ["", ""]
  else:
    data = [s[i-1], 'x']
  MAP.append(data)
  
for i in range(Q):
  place = lst[i][0]
  direction = lst[i][1]
  if direction == "L":
    for j in range(1,N+1):
      if MAP[j][0] == place:
        temp = MAP[j][1]
        MAP[j][1] = ""
        MAP[j-1][1] += temp
      else:
        pass
  else:
    for j in range(N, 0, -1):
      if MAP[j][0] == place:
        temp = MAP[j][1]
        MAP[j][1] = ""
        MAP[j+1][1] += temp
  MAP[0][1] = ""
  MAP[N+1][1] = ""


count = 0    
for i in range(1, N+1):
  c = MAP[i][1].count('x')
  count += c
  

print(count)