#include<bits/stdc++.h>
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
/*
bool isprime[10000];
vector<int> prime(10000);
int spf[10000];
void modified_era(){
    memset(isprime,true,sizeof isprime);
    isprime[1]=isprime[0]=false;
    for(ll i=2;i<10000;i++){
        if(isprime[i]){
            prime.push_back(i);

        }
        for(int j=0;j<prime.size() && i*prime[j]<10000;j++){
            isprime[i*prime[j]]=false;

        }

    }
    for(int i=0;i<10000;i++) if(isprime[i]) cout<<i<<endl;

    return;
}
bool is_prime(ll x){
    if(x==1) return(false);
    if(x==2 || x==3) return(true);
    if(x%2==0) return(false);
    if(x%3==0) return(false);
    for(ll p=5;p*p<=x;p++){
        if(x%p==0) return(false);
    }
    return(true);
}
ll fac[200001],finv[200001];

ll power(ll a,ll b){

    ll ans=1;
    while(b){
        if(b&1) ans=(ans*a);
        b/=2;
        a=(a*a);
    }
    return(ans);
}

ll inverse(ll a){
    return((power(a,MAX-2))%MAX);
}
ll ncr(ll n, ll r){
    ll p1=finv[n-r];
    ll p2=finv[r];

    return((((fac[n]*p1)%MAX)*p2)%MAX);


}
bool solve(ll n,ll arr[]){
    ll sum=0;
    for(ll i=0;i<n;i++){
        sum+=arr[i];
        if(sum<=0) return(false);
    }
    sum=0;
    for(ll i=n-1;i>=0;i--){
        sum+=arr[i];
        if(sum<=0) return(false);
    }
    return(true);
}
struct Node{
    ll l,r,w;
}arr[5001];

string cmp(string a,string b){
    if(a.size()>b.size()) return(a);
    if(b.size()>a.size()) return(b);
    int n=a.size();
    for(int i=0;i<n;i++){
        if(a[i]==b[i]) continue;
        if((a[i]-'0')>(b[i]-'0')) return(a);
        else return(b);
    }
    return(a);
}

map<string,int> mp;
bool is_previous(char a,char b){
    int n=a-'0',m=b-'0';
    return(m-n==1);
}
bool can(char a,char b,char c){
    return(is_previous(a,b)||is_previous(c,b));
}
int recur(string s,int n){
   // cout<<s<<endl;
    int ans=0;
    if(s=="") return(0);
    if(n==1) return(0);
    if(n==2){
        if(abs(s[0]-s[1])==1) {mp[s]=1;return(1);}
        else {mp[s]=0;return(0);}
    }

    string p="";
    if(is_previous(s[1],s[0])){
        if(mp[s.substr(1,n-1)]) ans=max(ans,1+mp[s.substr(1,n-1)]);
        else ans=max(ans,1+recur(s.substr(1,n-1),n-1));
    }
    for(int i=1;i+1<n;i++){
        if(can(s[i-1],s[i],s[i+1]))
          //  cout<<s<<endl;
            if(mp[s.substr(0,i)+s.substr(i+1,n-i-1)]) ans=max(ans,1+mp[s.substr(0,i)+s.substr(i+1,n-i-1)]);
            else ans=max(ans,1+recur(s.substr(0,i)+s.substr(i+1,n-i-1),n-1));
    }
    if(is_previous(s[n-2],s[n-1])){
        if(mp[s.substr(0,n-1)]) ans=max(ans,1+mp[s.substr(0,n-1)]);
        else ans=max(ans,1+recur(s.substr(0,n-1),n-1));
    }
    mp[s]=ans;
    return(ans);

}
*/
ll n,k,r,s,p;
ll cmp(char a,char b){
    if(a=='r' && b=='s') return(r);
    if(a=='s' && b=='p') return(s);
    if(a=='p' && b=='r') return(p);
    return(0);
}
int main(){
    IO

    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    t='!'+t;
    ll dp[n+1][3];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=k;i++){

        dp[i][0]=cmp('r',t[i]);
        dp[i][1]=cmp('s',t[i]);
        dp[i][2]=cmp('p',t[i]);
    }
    for(ll i=k+1;i<=n;i++){
        dp[i][0]=max(dp[i-k][1],dp[i-k][2])+cmp('r',t[i]);
        dp[i][1]=max(dp[i-k][0],dp[i-k][2])+cmp('s',t[i]);
        dp[i][2]=max(dp[i-k][1],dp[i-k][0])+cmp('p',t[i]);


    }
    /*
    for(ll i=1;i<=n;i++){
        cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    }
    */
    ll cnt=0;
    ll len=k;
    while(len){
        cnt+=max(dp[n-len+1][0],max(dp[n-len+1][1],dp[n-len+1][2]));
        len--;
    }
    cout<<cnt;

    return(0);
}

Measured memory_bytes: 6108