"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const INPUT = fs.readFileSync('/dev/stdin', 'utf-8');
const N = +INPUT.split('\n')[0].split(' ')[0];
const K = +INPUT.split('\n')[0].split(' ')[1];
const R = +INPUT.split('\n')[1].split(' ')[0];
const S = +INPUT.split('\n')[1].split(' ')[1];
const P = +INPUT.split('\n')[1].split(' ')[2];
const T = INPUT.split('\n')[2].split(' ')[0].split('');
// とにかく勝ち続ければ良い
let score = 0;
for (let n = 0; n < N; n++) {
    if (n >= K && T[n - K] === T[n]) {
        T[n] = '-';
        continue;
    }
    if (T[n] === 'r') {
        score += P;
    }
    else if (T[n] === 's') {
        score += R;
    }
    else {
        score += S;
    }
}
console.log(score);
