local n,k=io.read("n","n")
local R,S,P=io.read("n","n","n","l")
local t=io.read()
local a={}
local point=0

for i=1,n do
    if t:sub(i,i)=="r" then
        a[i]="p"
        point=point+P
    end
    if t:sub(i,i)=="s" then
        a[i]="r"
        point=point+R
    end
    if t:sub(i,i)=="p" then
        a[i]="s"
        point=point+S
    end
end

for i=1,n-k do
    if a[i]==a[i+k] then
        if a[i]=="p" then
            point=point-P
            a[i+k]=""
        end
        if a[i]=="r" then
            point=point-R
            a[i+k]=""
        end
        if a[i]=="s" then
            point=point-S
            a[i+k]=""
        end
    end
end

print(point)