#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second > b.second); 
}
int main() {
		/*#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif*/
fast();
//ll  t;cin>>t;while(t--)
{
   ll n,k,r,s,p,sum=0;
   string t;
   cin>>n>>k>>r>>s>>p;
   cin>>t;
   /*vector< pair<char,ll> >v;
    v.push_back(make_pair('r',r));
    v.push_back(make_pair('s',s));
    v.push_back(make_pair('p',p));
    sort(v.begin(),v.end(),sortbysec);
    for(int i=0;i<3;i++)
    {
    	cout<<v[i].first<<" ";
    }
    cout<<endl<<endl;
    string ss="";
      char y=v[0].first;
     for(int i=n-1;i-k>=0;i-=k)
     {
             if(t[i]==y)
             {

             }
     }

*/



string ss="";


   for(int i=0;i<n;i++)
   {
       if(t[i]=='r' && i<k)
       {
              sum+=p;
              //cout<<sum<<"  "<<i << endl;
              ss=ss+'p';
       }
       else if(t[i]=='r' &&i>=k)
       {
                if(ss[i-k]!='p')
                {
                	sum+=p;
                	//cout<<sum<<"  "<<i << endl;
                	ss=ss+'p';
                }
                else
                { if(i+k<n)
                	{
                	ss=ss+t[i+k];
                	}

                }

       }
       else if(t[i]=='s'&&i<k)
       {
       	      sum+=r;
       	      //cout<<sum<<"  "<<i << endl;
       	      ss=ss+'r';
       }
       else if(t[i]=='s' &&i>=k)
       {  
       	if(ss[i-k]!='r')
                {
                	sum+=r;
                	//cout<<sum<<"  "<<i << endl;
                	ss=ss+'r';
                }
                else
                { 

                	if(i+k<n)
                	{
                	ss=ss+t[i+k];
                	}
                	//ss=ss+'s';
                }

       }
      else  if(t[i]=='p'&&i<k)
       {  
       	  sum+=s;
       	  //cout<<sum<<"  "<<i << endl;
       	  ss=ss+'s';
       	
       	}
       	else if(t[i]=='p' &&i>=k)
       	{
             if(ss[i-k]!='s')
                {
                	sum+=s;
                	//cout<<sum<<"  "<<i << endl;
                	ss=ss+'s';
                }
                else
                {
                	if(i+k<n)
                	{
                	ss=ss+t[i+k];
                	}
                	
                	//ss=ss+'p';
                }
       	}
	
	

}
cout << sum << endl;
}
return 0;

}

Measured memory_bytes: 972