#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

ll n,k,r,s,p,ans;
string t;
bool ok[100009];

int main(){
    cin>>n>>k>>r>>s>>p>>t;
    rep(i,n){
        if(i<k||t[i-k]!=t[i]||ok[i-k]){
            if(t[i]=='r')ans+=p;
            if(t[i]=='p')ans+=s;
            if(t[i]=='s')ans+=r;
        }
        else ok[i]=1;
    }
    cout<<ans<<endl;
}