#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    lint n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;

    string t;
    cin >> t;

    lint dp[3][101010];
    fill(dp[0], dp[3], -LLINF);
    rep(i, min(k, n)){
        if(t[i] == 'r'){
            dp[0][i] = 0;
            dp[1][i] = 0;
            dp[2][i] = p;
        }else if(t[i] == 's'){
            dp[0][i] = r;
            dp[1][i] = 0;
            dp[2][i] = 0;
        }else{
            dp[0][i] = 0;
            dp[1][i] = s;
            dp[2][i] = 0;
        }
        for(int j = i ; j < n ; j += k){
            if(j + k < n){
                rep(l, 3){
                    rep(m, 3){
                        if(l == m){
                            continue;
                        }
                        if(t[j + k] == 'r'){
                            if(m == 2){
                                chmax(dp[m][j + k], dp[l][j] + p);
                            }else{
                                chmax(dp[m][j + k], dp[l][j]);
                            }
                        }else if(t[j + k] == 's'){
                            if(m == 0){
                                chmax(dp[m][j + k], dp[l][j] + r);
                            }else{
                                chmax(dp[m][j + k], dp[l][j]);
                            }
                        }else{
                            if(m == 1){
                                chmax(dp[m][j + k], dp[l][j] + s);
                            }else{
                                chmax(dp[m][j + k], dp[l][j]);
                            }
                        }
                    }
                }
            }
        }
    }

    lint ans = 0;
    rep(i, min(k, n)){
        ans += max({dp[0][n + ~i], dp[1][n + ~i], dp[2][n + ~i]});
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 2896