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


dp=Array.new(n){{"r"=>0,"s"=>0,"p"=>0}}

n.times{|i|
	if i<k
		dp[i]["r"] = t[i]=="s" ? r : 0
		dp[i]["s"] = t[i]=="p" ? s : 0
		dp[i]["p"] = t[i]=="r" ? p : 0
	else
		dp[i]["r"] = [dp[i-k]["s"], dp[i-k]["p"]].max + (t[i]=="s" ? r : 0)
		dp[i]["s"] = [dp[i-k]["r"], dp[i-k]["p"]].max + (t[i]=="p" ? s : 0)
		dp[i]["p"] = [dp[i-k]["r"], dp[i-k]["s"]].max + (t[i]=="r" ? p : 0)
	end
}

x=0
k.times{|i|
	x+=dp[~i].values.max
}

p x