#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

// 165 -d
int main() {
    int n, k;
    cin >> n >> k;

    int pr, ps, pp;
    cin >> pr >> ps >> pp;

    string hstr = "";
    cin >> hstr;  // size: n;
    vector<vector<int>> opHands(k, vector<int>());
    rep(i, 0, n) {
        int hint = 0;
        if (hstr[i] == 'r') {
            hint = 0;
        } else if (hstr[i] == 's') {
            hint = 1;
        } else if (hstr[i] == 'p') {
            hint = 2;
        }

        opHands[i % k].push_back(hint);
    }

    /* mod k ごとに総和を求める */
    int sumscore = 0;
    rep(i, 0, k) {
        int corr[3] = {0, 0, 0}, next[3] = {0, 0, 0};
        // printf("calc: ");
        // for (int v : opHands[i]) { printf("%d ", v); }
        // printf("\n");

        rep(j, 0, opHands[i].size()) {
            rep(ic, 0, 3) {
                rep(in, 0, 3) {
                    if (ic == in) continue;

                    int tscore = 0;
                    if (in == 0 && opHands[i][j] == 1) {
                        tscore = pr;
                    } else if (in == 1 && opHands[i][j] == 2) {
                        tscore = ps;
                    } else if (in == 2 && opHands[i][j] == 0) {
                        tscore = pp;
                    }
                    // printf("  %d-%d -> %d\n", ic, in, tscore);

                    next[in] = max(next[in], corr[ic] + tscore);
                }
            }
            // for (int v : next) { printf(" %d", v); }
            // printf("\n");

            swap(corr, next);
        }
        int tscore = max(corr[0], max(corr[1], corr[2]));
        // printf("  score: %d\n", tscore);
        // sumscore += max(corr[0], max(corr[1], corr[2]));
        sumscore += tscore;
    }

    cout << sumscore << endl;

    /* score: 0-> rock, 1-> scissors, 2 -> paper */
    // string handType = "rsp";
    // vector<int> score(0, n+1);

    // typedef pair<int, string> score;
    // /* vscore[n][i]: n回目の手iのスコア(first: point, second: history); */
    // vector<vector<score>> vscore(n + 1, vector<score>(3, {0, ""}));

    // repe(_n, 1, n) {
    //     rep(previdx, 0, 3) {
    //         rep(corridx, 0, 3) {
    //             /* 同じ手は連続しない */
    //             if (previdx == corridx) continue;
    //             int getScore = 0;
    //             if (handType[corridx] == 'r' && macHands[_n] == 's') {
    //                 getScore = pr;
    //             } else if (handType[corridx] == 's' && macHands[_n] == 'p') {
    //                 getScore = ps;
    //             } else if (handType[corridx] == 'p' && macHands[_n] == 'r') {
    //                 getScore = pp;
    //             }
    //             corScore[corridx] = max(corScore[corridx], preScore[previdx] + getScore);
    //         }
    //     }
    //     printf("%d (%c): %d %d %d\n", _n, macHands[_n], corScore[0], corScore[1],
    //     corScore[2]); swap(preScore, corScore);
    // }

    // repe(_n, 1, n) {
    //     char ophand = macHands[_n];
    //     rep(previdx, 0, 3) {
    //         rep(corridx, 0, 3) {
    //             // if(_n > k) {
    //             // // k回前の手とかぶっらない
    //             // countinue;
    //             // }

    //             int getScore = 0;
    //             char myhand  = handType[corridx];
    //             if (myhand == 'r' && ophand == 's') {
    //                 getScore = pr;
    //             } else if (myhand == 's' && ophand == 'p') {
    //                 getScore = ps;
    //             } else if (myhand == 'p' && ophand == 'r') {
    //                 getScore = pp;
    //             }

    //             if (vscore[_n][corridx] >= vscore[_n - 1][previdx] + getScore) {}
    //         }
    //     }

    //     cout << max(preScore[0], max(preScore[1], preScore[2])) << endl;

    return 0;
}



Measured memory_bytes: 5120