class SubString
  BASE = 101

  def initialize
    @n = 0
    @m = 0
    @str = ''
    @length = 0
    @hash = 0
    @l = 0
    @r = 0
  end

  def r_plus
    @r += 1
    @hash *= BASE
    @hash += @str[@r].ord
    @length += 1
    @hash
  end

  def r_minus
    @hash -= @str[@r].ord
    @hash /= BASE
    @length -= 1
    @r -= 1
    @hash
  end

  def l_plus
    @hash -= @str[@l].ord * (BASE ^ (@length - 1))
    @length -= 1
    @l += 1
    @hs
  end

  def l_minus
    @l -= 1
    @length += 1
    @hash += @str[@l].ord * (BASE ^ (@length - 1))
    @hash
  end

  def get_string_hash query
    case query
    when 'R++' then r_plus
    when 'R--' then r_minus
    when 'L++' then l_plus
    when 'L--' then l_minus
    end
  end

  def main
    @n, @m = gets.chomp.split.map(&:to_i)
    @str = gets.chomp

    s = {}
    @m.times do
      query = gets
      break if query.nil?
      query.chomp!
      hash = get_string_hash(query)
      s[hash] = 1
    end

    puts s.size
  end
end

SubString.new.main