// Template //
#include<bits/stdc++.h>
using namespace std;

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int N, K, R, S, P;
    string T;
    map<char, int> pt;
    cin >> N >> K >> R >> S >> P >> T;
    char r = 'r', s = 's', p = 'p';
    pt[r] = P;
    pt[s] = R;
    pt[p] = S;
    int sum = 0;
    rep(i, N) {
        if (T[i] == r) sum += pt[r];
        if (T[i] == s) sum += pt[s];
        if (T[i] == p) sum += pt[p];
    }
    int rconseq = 0, sconseq = 0, pconseq = 0;

    rep(i, K) {
        for (int j = i; j < T.size(); j += K) {
            if (T[j] == r) {
                rconseq++;
                sum -= (sconseq / 2) * pt[s];
                sum -= (pconseq / 2) * pt[p];
                sconseq = 0;
                pconseq = 0;
            }
            if (T[j] == s) {
                sconseq++;
                sum -= (pconseq / 2) * pt[p];
                sum -= (rconseq / 2) * pt[r];
                pconseq = 0;
                rconseq = 0;
            }
            if (T[j] == p) {
                pconseq++;
                sum -= (rconseq / 2) * pt[r];
                sum -= (sconseq / 2) * pt[s];
                rconseq = 0;
                sconseq = 0;
            }
        }
        sum -= (rconseq / 2) * pt[r];
        sum -= (sconseq / 2) * pt[s];
        sum -= (pconseq / 2) * pt[p];
        rconseq = 0;
        sconseq = 0;
        pconseq = 0;
    }
    cou(sum);
}

Measured memory_bytes: 512