// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = int64_t;



ll N, K, R, S, P;

string T;



array<vector<ll>, 3> memo = { vector<ll>(100000 * 3, -1), vector<ll>(100000 * 3, -1), vector<ll>(100000 * 3, -1) };

const map<char, size_t> hand2i = { { 'r', 0 }, { 's', 1 }, { 'p', 2 } };



ll dfs(char hand, int index, int a)

{

    if (index * K >= N) {

        return 0;

    }



    auto hand_index = index * K + a;

    auto& memo_r = memo[hand2i.at(hand)][hand_index];

    if (memo_r != -1) {

        return memo_r;

    }



    auto enemy_hand = T[hand_index];

    ll score = 0;

    if (hand == 'r') {

        if (enemy_hand == 's') {

            score += R;

        }

        score += max(dfs('s', index + 1, a), dfs('p', index + 1, a));

    }

    if (hand == 's') {

        if (enemy_hand == 'p') {

            score += S;

        }

        score += max(dfs('r', index + 1, a), dfs('p', index + 1, a));

    }

    if (hand == 'p') {

        if (enemy_hand == 'r') {

            score += P;

        }

        score += max(dfs('r', index + 1, a), dfs('s', index + 1, a));

    }



    memo_r = score;

    return score;

}



void main_()

{

    cin >> N >> K >> R >> S >> P;

    cin >> T;



    ll ans = 0;

    for (ll i = 0; i < K; ++i) {

        ans += max({

            dfs('r', 0, i),

            dfs('s', 0, i),

            dfs('p', 0, i),

        });

    }

    cout << ans << endl;

}

int main()

{

    cin.tie(nullptr);

    cout.tie(nullptr);

    ios_base::sync_with_stdio(false);

    main_();

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll = int64_t;



ll N, K, R, S, P;

string T;



array<vector<ll>, 3> memo = { vector<ll>(100000, -1), vector<ll>(100000, -1), vector<ll>(100000, -1) };

array<char, 256> c2i;



ll dfs(char hand, int index, int a)

{

    if (index * K + a >= N) {

        return 0;

    }



    auto hand_index = index * K + a;

    auto& memo_r = memo[c2i[hand]][hand_index];

    if (memo_r != -1) {

        return memo_r;

    }



    auto enemy_hand = T[hand_index];

    ll score = 0;

    if (hand == 'r') {

        if (enemy_hand == 's') {

            score += R;

        }

        score += max(dfs('s', index + 1, a), dfs('p', index + 1, a));

    }

    if (hand == 's') {

        if (enemy_hand == 'p') {

            score += S;

        }

        score += max(dfs('r', index + 1, a), dfs('p', index + 1, a));

    }

    if (hand == 'p') {

        if (enemy_hand == 'r') {

            score += P;

        }

        score += max(dfs('r', index + 1, a), dfs('s', index + 1, a));

    }



    memo_r = score;

    return score;

}



void main_()

{

    cin >> N >> K >> R >> S >> P;

    cin >> T;



    c2i['r'] = 0;

    c2i['s'] = 1;

    c2i['p'] = 2;



    ll ans = 0;

    for (ll i = 0; i < K; ++i) {

        ans += max({

            dfs('r', 0, i),

            dfs('s', 0, i),

            dfs('p', 0, i),

        });

    }

    cout << ans << endl;

}

int main()

{

    cin.tie(nullptr);

    cout.tie(nullptr);

    ios_base::sync_with_stdio(false);

    main_();

    return 0;

}


// Fastest known solution for this problem: