#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b)
{
   ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a);
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)     for (int i = 0; i < int(n); i++)
#define  forr(i, n)     for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)  
#define  deb(x)       cout << '>' << #x << ':' << x << endl;
void solve()
{
    int n,k;
    cin>>n>>k;
    int r,p,s;
    cin>>r>>s>>p;
    string moves,mm="";
    cin>>moves;
    ll ans=0;
    forn(i,n)
    {
        if(i<k)
        {
            if(moves[i]=='r')
            {
                mm+='p';
                ans+=p;
            }
            else if(moves[i]=='s')
            {
                mm+='r';
                ans+=r;
            }
            else if(moves[i]=='p')
            {
                mm+='s';
                ans+=s;
            }
        }
        else
        {
            if(moves[i]=='r')
            {
            if(moves[i]=='r'&&mm[i-k]!='p')
            {
                mm+='p';
                ans+=p;
                continue;
            }
            else
            {
                if(i+k<n&&moves[i+k]!='p')mm+='s';
                else mm+='r';
                continue;
            }
            }
            else if(moves[i]=='s')
            {
            if(moves[i]=='s'&&mm[i-k]!='r')
            {
                mm+='r';
                ans+=r;
                continue;
            }
            else
            {
                if(i+k<n&&moves[i+k]!='r')mm+='p';
                else mm+='s';
                ans+=0;
                continue;
            }
            }
            else
            {
            if(moves[i]=='p'&&mm[i-k]!='s')
            {
                mm+='s';
                ans+=s;
                continue;
            }
            else
            {
                if(i+k<n&&moves[i+k]!='s')mm+='r';
                else mm+='p';
                ans+=0;
                continue;
            }
            }
        }
    }
    //cout<<mm<<endl;
    cout<<ans<<endl;
}
int main()
{
    FastIO;
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 640