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

a = Array.new(k).map{Array.new(n/k)}

for i in 0..n-1
    a[i%k][i/k] = t[i]
end
w = [0,0,0]
for i in 0..k-1
    flag = 0 #前に負けてたら１
    for j in 0..a[i].length-1
        if flag == 1 || j==0
            if a[i][j] == 's'
                w[0] += 1
            elsif a[i][j] == 'p'
                w[1] += 1
            else
                w[2] += 1
            end
            flag = 0
        else
            if a[i][j-1]==a[i][j]
                flag = 1
                next
            end
            if a[i][j] == 's'
                w[0] += 1
            elsif a[i][j] == 'p'
                w[1] += 1
            else
                w[2] += 1
            end
        end
    end
end

ans = w[0]*r+w[1]*s+w[2]*p

puts ans