class SubString
  def initialize
    @n = 0
    @m = 0
    @str = ''
    @sub_str = ''
    @l = 0
    @r = 0
  end

  def r_plus
    @r += 1
    @sub_str << @str[@r]
    @sub_str
  end

  def r_minus
    @sub_str.slice!(@sub_str.length-1)
    @r -= 1
    @sub_str
  end

  def l_plus
    @sub_str.slice!(0)
    @l += 1
    @sub_str
  end

  def l_minus
    @l -= 1
    @sub_str = @str[@l] + @sub_str
    @sub_str
  end

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

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

    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