#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)

//MIN-MAX
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	ll n,k;
	  cin>>n>>k;
	  ll r,s,p;
	   cin>>r>>s>>p;
	  string str;
	   cin>>str;
	   ll ans=0;
	   const int le=str.length();
	   string ans_str="";
	   for(int i=0;i<k;i++)
       {
           if(str[i]=='r')
           {
               ans+=p;
               ans_str.push_back('p');
           }
           else if(str[i]=='p')
           {
               ans+=s;
               ans_str.push_back('s');
           }
           else
           {
               ans+=r;
               ans_str.push_back('r');
           }

       }

       for(int i=k;i<le;i++)
       {
           if(str[i]=='r')
           {
               if(ans_str[i-k]=='p')
               {
                   if(i+k>=le)
                    ans_str.push_back('s');
                   else
                   {
                       if(str[i+k]=='p')
                        ans_str.push_back('r');
                       else
                        ans_str.push_back('s');
                   }
               }
               else
               {
                   ans+=p;
                   ans_str.push_back('p');
               }
           }
           else if(str[i]=='p')
           {
               if(ans_str[i-k]=='s')
               {
                   if(i+k>=le)
                    ans_str.push_back('r');
                   else
                   {
                       if(str[i+k]=='s')
                        ans_str.push_back('p');
                       else
                        ans_str.push_back('r');
                   }
               }
               else
                {
                    ans+=s;
                   ans_str.push_back('s');
               }
           }
           else
           {
              if(ans_str[i-k]=='r')
               {
                   if(i+k>=le)
                    ans_str.push_back('p');
                   else
                   {
                       if(str[i+k]=='r')
                        ans_str.push_back('s');
                       else
                        ans_str.push_back('p');
                   }
               }
               else
               {
                   ans+=r;
                   ans_str.push_back('r');
               }
           }



       }
         cout<<ans<<"\n";
          // cout<<ans_str<<"\n";

	return 0;
}













Measured memory_bytes: 512