lines = []
while line = gets
    lines << line.chomp.split(' ')
end

N = lines[0][0].to_i
K = lines[0][1].to_i
R = lines[1][0].to_i
S = lines[1][1].to_i
P = lines[1][2].to_i
T = lines[2][0]

a = []
for i in 1..K do
  a[i-1] = []
end

for i in 1..N do
  mod = i % K
  a[mod].push(T[i-1])
end

def point(x)
  if x == "r" then
    return P
  elsif x == "p" then
    return S
  else
    return R
  end
end
    
def win(x)
  if x == "s"
    return "r"
  elsif x == "r"
    return "p"
  else
    return "s"
  end
end

score = 0
for i in 0..K-1 do
  previous = "x"
  for j in 1..a[i].length do
    if previous != win(a[i][j-1]) then
      score += point(a[i][j-1])
      previous = win(a[i][j-1])
    else
      previous = "x"
    end
  end
end
    
print score