#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


ll foo(ll a, int b){
    ll ans = 0;
    while(a){
        if (a%b == 0) ans++;
        else break;
        a/=b;
    }
    rn ans;
}



vector<ll> a(101010);
vector<ll> cumsum(101010);
ll pth = 0LL;

bool check(ll i, ll p, ll t, ll m, ll v, ll n, ll c, ll extra){
    
    ll diff = cumsum[i-1]-cumsum[p-1];
    
    ll times = 0LL;
    times = a[p-1]-a[i];

    ll z = 0LL;
    if (n-v-1>0) z = n - v- 1;
    else z = 0;
    
    
    //cout << t*pth << " "<< diff + times*(t-min(t,z)) << " " << diff << " " <<  times << " " << t << " " << z << endl;
    
    if (times > m){
        rn false;
    }
    if (t*pth >= diff + times*(t-min(t,z))) rn true;
    else if ((-t*pth+(diff + times*(t-min(t,z))))/(min(z+1,t + c-extra)) < (m-times)){
        //cout << t <<" "<<  m - times << endl;
        rn true;
    }
    else{
        rn false;
    }
}


bool check(int x){
    int sqr = sqrt(x);
    FOR(j,2,sqr+1){
        if(x%j == 0){
            rn false;
        }
    }
    
    rn true;
}


int main(){
    int n,k;
    cin >> n >> k;
    
    int r,s,p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    ll ans = 0;
    vector<int> visited(n,-1);
    
    rep(i,k){
        visited[i] = 1;
        if (t[i] == 'r'){
            ans +=p;
        }
        if (t[i] == 's'){
            ans +=r;
        }
        if (t[i] == 'p'){
            ans +=s;
        }
    }
    
    FOR(i,k,n){
        if (visited[i] == -1){
            visited[i] = 1;
            
            int j = i + k;
            int count = 1;
            int same = 0;
            
            if (t[i] == t[i-k]) same = 1;
            
            while(j<n){
                if (visited[j] == -1){
                    if (t[j] == t[i]){
                        count++;
                        visited[j] = 1;
                    }
                    else{
                        break;
                    }
                }
                j += k;
                
            }
            //cout << count << t[i] << ":" << same << ":"<< (count + 1 + same)/2 - same << " ";
            count = (int)((count + 1 + same)/2 - same);
            
            if (t[i] == 'r'){
                ans +=p*count;
            }
            if (t[i] == 's'){
                ans +=r*count;
            }
            if (t[i] == 'p'){
                ans +=s*count;
            }
        }
    }
    
    cout << ans;
}
int main1(){
    int x;
    cin >> x;
    FOR(i,x,2*x){
        if (check(i)){
            cout << i;
            rn 0;
        }
    }
    rn 0;
}


Measured memory_bytes: 2432