#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template<typename T>
T gcd(T a, T b){
    while(b){
        a %= b;
        swap(a, b);
    }
    return a;
}
struct TwoStacks{
    using T = long long;
    struct Node{
        T val, sum;
        Node(const T &val, const T &sum):val(val), sum(sum){}
    };
    T merge(T l, T r){
        return gcd(l, r);
    }
    stack<Node> front, back;
    int size(){
        return front.size() + back.size();
    }
    T eval(){
        //        assert(front.size() + back.size() > 0);
        if(!back.empty()){
            if(!front.empty()){
                return merge(front.top().sum, back.top().sum);
            }else{
                return back.top().sum;
            }
        }else{
            return front.top().sum;
        }
    }
    void pop_front(){
        //        assert(front.size() + back.size() > 0);
        if(front.empty()){
            front.emplace(back.top().val, back.top().val);
            back.pop();
            while(!back.empty()){
                front.emplace(back.top().val, merge(back.top().val, front.top().sum));
                back.pop();
            }
        }
        front.pop();
    }
    void push_back(const T &val){
        if(!back.empty()){
            back.emplace(val, merge(back.top().sum, val));
        }else{
            back.emplace(val, val);
        }
    }
};
int main(){
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    string ans;
    rep(i,n)ans+=" ";
    int res = 0;
    rep(i,n){
        char x = t[i];
        if(x == 'r'){
            if(i - k >= 0 and ans[i-k]=='p'){
                //r,or,s
                if(i + k < n and t[i + k] == 's'){
                    ans[i] = 's';
                }else{
                    ans[i] = 'r';
                }
            }else{
                ans[i] = 'p';
                res+=p;
            }
        }else if(x == 's'){
            if(i - k >= 0 and ans[i-k]=='r'){
                //s or p
                if(i + k < n and t[i + k] == 'p'){
                    ans[i] = 'p';
                }else{
                    ans[i] = 's';
                }
            }else{
                ans[i] = 'r';
                res+=r;
            }
        }else{
            if(i - k >= 0 and ans[i-k]=='s'){
                if(i + k < n and t[i + k] == 'r'){
                    ans[i] = 'r';
                }else{
                    ans[i] = 'p';
                }
            }else{
                ans[i] = 's';
                res+=s;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 640