N, Q = gets.chomp.split(' ').map(&:to_i)
S = gets.chomp
SPELL_LIST = Q.times.map { gets.chomp.split(' ') }

def last_position(i)
  pos = i
  SPELL_LIST.each do |t, d|
    ch = S[pos]
    next unless t == ch
    if d == 'L'
      pos -= 1
    else
      pos += 1
    end
    if pos < 0
      return -1
    elsif pos > N - 1
      return N
    end
  end
  return pos
end

def last_left_dropped_pos(l, r)
  return nil if l > r
  center = l + ((r - l) / 2)
  pos = last_position(center)
  if pos == -1
    last_left_dropped_pos(center + 1, r) || center
  elsif pos == N
    last_left_dropped_pos(l, center - 1)
  else
    last_left_dropped_pos(l, center - 1)
  end
end

def last_right_dropped_pos(l, r)
  return nil if l > r
  center = l + ((r - l) / 2)
  pos = last_position(center)
  if pos == -1
    last_right_dropped_pos(center + 1, r)
  elsif pos == N
    last_right_dropped_pos(l, center - 1) || center
  else
    last_right_dropped_pos(center + 1, r)
  end
end

left = last_left_dropped_pos(0, N - 1)
right = last_right_dropped_pos(left || 0, N - 1)
ans = N - (left.nil? ? 0 : left + 1) - (right.nil? ? 0 : N - 1 - right + 1)
puts ans
