#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = int64_t;

int main() {
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    vector<string> kmod(k, "");
    rep(i, n) {
        kmod[i % k].push_back(t[i]);
    }

    ll score = 0LL;
    for (string opp : kmod)
    {
        string me = "";
        rep(i, opp.size())
        {
            if (i == 0) {
                if (opp[i] == 'r') {
                    me.push_back('p');
                    score += p;
                }
                if (opp[i] == 's') {
                    me.push_back('r');
                    score += r;
                }
                if (opp[i] == 'p') {
                    me.push_back('s');
                    score += s;
                }
            } else if (opp[i-1] == opp[i] && i + 1 < opp.size()) {
                if (opp[i + 1] == 'r') {
                    if (opp[i-1] == 'r') {
                        if (me[i-1] == 'p')
                            me.push_back('r');
                        else {
                            me.push_back('p');
                            score += p;
                        }
                    }
                    if (opp[i-1] == 's') {
                        if (me[i-1] == 'r')
                            me.push_back('s');
                        else {
                            me.push_back('r');
                            score += r;
                        }
                    }
                    if (opp[i-1] == 'p') {
                        if (me[i-1] == 's')
                            me.push_back('r');
                        else {
                            me.push_back('s');
                            score += s;
                        }
                    }
                }

                if (opp[i + 1] == 's') {
                    if (opp[i-1] == 'r') {
                        if (me[i-1] == 'p')
                            me.push_back('s');
                        else {
                            me.push_back('p');
                            score += p;
                        }
                    }
                    if (opp[i-1] == 's') {
                        if (me[i-1] == 'r')
                            me.push_back('s');
                        else {
                            me.push_back('r');
                            score += r;
                        }
                    }
                    if (opp[i-1] == 'p') {
                        if (me[i-1] == 's')
                            me.push_back('p');
                        else {
                            me.push_back('s');
                            score += s;
                        }
                    }
                }

                if (opp[i + 1] == 'p') {
                    if (opp[i-1] == 'r') {
                        if (me[i-1] == 'p')
                            me.push_back('r');
                        else {
                            me.push_back('p');
                            score += p;
                        }
                    }
                    if (opp[i-1] == 's') {
                        if (me[i-1] == 'r')
                            me.push_back('p');
                        else {
                            me.push_back('r');
                            score += r;
                        }
                    }
                    if (opp[i-1] == 'p') {
                        if (me[i-1] == 's')
                            me.push_back('r');
                        else {
                            me.push_back('s');
                            score += s;
                        }
                    }
                }
            }else if (opp[i-1] == opp[i]) {

                if (opp[i-1] == 'r') {
                    if (me[i-1] == 'p')
                        me.push_back('r');
                    else {
                        me.push_back('p');
                        score += p;
                    }
                }
                if (opp[i-1] == 's') {
                    if (me[i-1] == 'r')
                        me.push_back('s');
                    else {
                        me.push_back('r');
                        score += r;
                    }
                }
                if (opp[i-1] == 'p') {
                    if (me[i-1] == 's')
                        me.push_back('r');
                    else {
                        me.push_back('s');
                        score += s;
                    }
                }
            } else {
                    if (opp[i] == 'r')
                    {
                        me.push_back('p');
                        score += p;
                    }
                    if (opp[i] == 's')
                    {
                        me.push_back('r');
                        score += r;
                    }
                    if (opp[i] == 'p')
                    {
                        me.push_back('s');
                        score += s;
                    }
            }

        }
    }

    cout << score << endl;
}


Measured memory_bytes: 5120