#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
R,S,P=get_i
T=get_nsp
group=array(K)
T.each_with_index do|t,i|
    group[i%K]=[] if group[i%K].nil?
    group[i%K].push(t)
end

def DP(n,t)
    dp=Array.new(n+1){Array.new(3){0}}
    n.times do|i|
        case t[i]
        when "r" then
            dp[i+1][0]=max(dp[i][1],dp[i][2])
            dp[i+1][1]=max(dp[i][0],dp[i][2])
            dp[i+1][2]=max(dp[i][0],dp[i][1])+P
        when "s" then
            dp[i+1][0]=max(dp[i][1],dp[i][2])+R
            dp[i+1][1]=max(dp[i][0],dp[i][2])
            dp[i+1][2]=max(dp[i][0],dp[i][1])
        when "p" then
            dp[i+1][0]=max(dp[i][1],dp[i][2])
            dp[i+1][1]=max(dp[i][0],dp[i][2])+S
            dp[i+1][2]=max(dp[i][0],dp[i][1])
        end
    end
    return dp[n].max
end
ans=0
group.each do|g|
  ans+=DP(g.size,g)
end
puts ans