//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, k;
int r, s, p;
string t;
string str[N];

vector<int> dp[4];

//mapping

//r => 0
//s => 1
//t => 2

int getmapping(char c){
   if(c == 'r')
      return 0;
   if(c == 's')
      return 1;
   return 2;
}

int rq;
int solve(int idx, string &s, int prev){
   if (idx >= sz(s)){
      return 0;
   }

   int &ans = dp[prev+1][idx];
   if(ans != -1)
      return ans;

   ans = -inf;
   int curr = getmapping(s[idx]);
   for (int i = 0; i < 3; ++i)
   {
      if(i == prev)
         continue;
      if(i == 0){//rock
         if(curr == 0){
            smax(ans, 0 + solve(idx+1, s, i));
         }
         else if (curr == 1){
            smax(ans, r + solve(idx+1, s, i));            
         }
         else{
            smax(ans, 0 + solve(idx+1, s, i));
         }
      }
      else if (i == 1){//scissors
         if(curr == 0){
            smax(ans, 0 + solve(idx+1, s, i));
         }
         else if (curr == 1){
            smax(ans, 0 + solve(idx+1, s, i));            
         }
         else{
            smax(ans, ::s + solve(idx+1, s, i));
         }
      }
      else{//paper
         if(curr == 0){
            smax(ans, p + solve(idx+1, s, i));
         }
         else if (curr == 1){
            smax(ans, 0 + solve(idx+1, s, i));            
         }
         else{
            smax(ans, 0 + solve(idx+1, s, i));
         }         
      }
   }
   return ans;
}

int32_t main(){_
   
   cin >> n >> k;
   cin >> r >>  s >> p;

   cin >> t;

   int ans = 0;
   
   for (int i = 0; i < n; ++i)
   {
      str[i%k] += t[i];
   }

   ans = 0;
   for (int i = 0; i < k; ++i)
   {
      for (int j = 0; j < 4; ++j)
         dp[j].assign(sz(str[i]), -1);
      rq = i;
      ans += solve(0, str[i], -1);
   }


   // for (int i = 0; i < k; ++i)
   // {
   //    if(t[i] == 'r'){
   //       str[i] = 'p';
   //       ans += p;
   //    }
   //    if(t[i] == 's'){
   //       str[i] = 'r';
   //       ans += r;
   //    }
   //    if(t[i] == 'p'){
   //       str[i] = 's';
   //       ans += s;
   //    }
   // }

   // for (int i = k; i < n; ++i)
   // {
   //    if(t[i] == 'r'){
   //       if(str[i-k] != 'p'){
   //          str[i] = 'p';
   //          ans += p;
   //       }
   //       else{
   //          str[i] = 'r';
   //       }
   //    }
   //    else if (t[i] == 's'){
   //       if(str[i-k] != 'r'){
   //          str[i] = 'r';
   //          ans += r;
   //       }
   //       else{
   //          str[i] = 's';
   //       }         
   //    }
   //    else{
   //       if(str[i-k] != 's'){
   //          str[i] = 's';
   //          ans += s;
   //       }
   //       else{
   //          str[i] = 'p';
   //       }
   //    }
   // }
   
   cout<<ans;

   return 0;
}

Measured memory_bytes: 13776