//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    /*int x;cin>>x;
    if(x==2){
        cout<<2<<endl;
        return 0;
    }
    if(x%2==0)x++;
    for(int i=x;i<INF;i+=2){
        if(IsPrime(i)){
            cout<<i<<endl;
            return 0;
        }
    }*/
    int n,k;cin>>n>>k;   //r 0 s 1 p 2 r>s s>p p>r
    int r,s,p;cin>>r>>s>>p;
    string t;cin>>t;
    ll dp[100001];
    memset(dp, 0, sizeof(dp));int color[100001][3];
    memset(color,0,sizeof(color));
    if(t[0]=='r'){
        dp[0]=p;
        color[0][0]=1;
    }
    else if(t[0]=='s'){
        dp[0]=r;color[0][1]=1;
    }
    else if(t[0]=='p'){
        dp[0]=s;color[0][2]=1;
    }
    
    for(int i=1;i<k;i++){
        if(t[i]=='r'){
            chmax(dp[i],p+dp[i-1]);
            color[i][0]=1;
        }
        else if(t[i]=='s'){
            chmax(dp[i],r+dp[i-1]);
            color[i][1]=1;
        }
        else if(t[i]=='p'){
            chmax(dp[i],s+dp[i-1]);
         
            color[i][2]=1;
        }
        //cout<<dp[i]<<endl;
    }
    for(int i=k;i<n;i++){
        
        if(t[i]==t[i-k]){
            if(t[i]=='r'){
                //cout<<color[i-k][0]<<endl;
                if(color[i-k][0]==1){
                    color[i][0]=0;
                    dp[i]=dp[i-1];
                    //cout<<dp[i]<<endl;
                    continue;
                }
            }
            else if(t[i]=='s'){
                if(color[i-k][1]==1){
                    color[i][1]=0;
                    dp[i]=dp[i-1];
                    continue;
                }
            }
            else if(t[i]=='p'){
                if(color[i-k][2]==1){
                    color[i][2]=0;
                    dp[i]=dp[i-1];
                    continue;
                }
            }
            
        }
      
            if(t[i]=='r'){
                chmax(dp[i],p+dp[i-1]);
                color[i][0]=1;
            }
            else if(t[i]=='s'){
                chmax(dp[i],r+dp[i-1]);
                color[i][1]=1;
            }
            else if(t[i]=='p'){
                chmax(dp[i],s+dp[i-1]);
                color[i][2]=1;
            }
        
        
       //cout<<dp[i]<<endl;
        
    }
    ll ans=0;
        chmax(ans,dp[n-1]);
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 2432