n, k = STDIN.gets.split.map(&:to_i)
r, s, p = STDIN.gets.split.map(&:to_i)
t = STDIN.gets.strip.split('')

arrays = t.size.times.inject([]) {|array, index|
  array[index % k] = [] unless array[index % k]
  array[index % k] << t[index]
  array
}

scores = arrays.map {|array|

  before = ''

  array.map {|i|
    case i
    when before
      before = ''
      0
    when 'r'
      before = i
      p
    when 's'
      before = i
      r
    when 'p'
      before = i
      s
    end
  }
}

puts scores.flatten.inject(0) {|acc, i| i + acc }