#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

int n, k;
ll r, p, s;
int d[100010];

string t;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    char c;
    c = t[0];
    ll sol = 0;
    if (c == 'r') {
        d[1] = 1;
        sol += p;
    }
    else if (c == 'p') {
        d[1] = 2;
        sol += s;
    }
    else {
        d[1] = 0;
        sol += r;
    }

    Rep(i, 2, k) {
        c = t[i-1];

        if (c == 'r') {
            d[i] = 1;
            sol += p;
        }
        else if (c == 'p') {
            d[i] = 2;
            sol += s;
        }
        else {
            d[i] = 0;
            sol += r;
        }
    }

    Rep(i, k+1, n) {
        c = t[i-1];

        if (c == 'r') {
            if (d[i-k] != 1) {
                d[i] = 1;
                sol += p;
            }
            else {
                d[i] = 3;
            }
        }
        else if (c == 'p') {
            if (d[i-k] != 2) {
                d[i] = 2;
                sol += s;
            }
            else {
                d[i] = 3;
            }
        }
        else {
            if (d[i-k] != 0) {
                d[i] = 0;
                sol += r;
            }
            else {
                d[i] = 3;
            }
        }
    }

    cout << sol << '\n';
    return 0;
}


Measured memory_bytes: 848