function Main(input) {
  var vals = input.trim().split(/\s+/);
  var N = parseInt(vals[0]);
  var K = parseInt(vals[1]);
  var R = parseInt(vals[2]);
  var S = parseInt(vals[3]);
  var P = parseInt(vals[4]);
  var T = vals[5];
  
  var getScore = (n, h) =>
    T[n] == 'r' && h == 'p'? P:
    T[n] == 's' && h == 'r'? R:
    T[n] == 'p' && h == 's'? S:
    0;
  var getBestScore = (n, nh) =>
    T[n] == 'r' && nh != 'p'? P:
    T[n] == 's' && nh != 'r'? R:
    T[n] == 'p' && nh != 's'? S:
    0;
  var getSumScore = (n, h) => {
    var score_ = getScore(n, h);
    for (var n_ = n + K; n_ < N; n_ += K)
      score_ += getBestScore(n_, h);
    return score_;
  };
  var getBestSumScore = n => {
    var rs_ = getSumScore(n, 'r');
    var ss_ = getSumScore(n, 's');
    var ps_ = getSumScore(n, 'p');
    return Math.max(rs_, ss_, ps_);
  };

  var score = 0;
  for (var n = 0; n < K; n++)
    score += getBestSumScore(n);
  console.log(score);
};
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
