#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,k,r,s,p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  reverse(all(t));
  ll aws = 0;
  for(ll m = 0;m < k; m++){
    //pri2("m",m);
    ll mama = ((n - m) + k - 1) / k;
    //pri2("mama",mama);
    ll ans[1][mama+1][4];
    rep(j,mama+1){
      ans[0][j][1] = 0;
      ans[0][j][2] = 0;
      ans[0][j][3] = 0;
    }
    for(ll i = 0;i < mama; i++){
      ll pp = 0;
      ll gg = 0;
      ll cc = 0;
      if(t[i*k+m]=='p') cc = s;
      if(t[i*k+m]=='s') gg = r;
      if(t[i*k+m]=='r') pp = p;
      // 1
      chmax(ans[0][i+1][1],max(ans[0][i][2]+pp,ans[0][i][3]+pp));
      //pri(ans[0][i+1][1]);
      // 2
      chmax(ans[0][i+1][2],max(ans[0][i][1]+gg,ans[0][i][3]+gg));
      //pri(ans[0][i+1][2]);
      // 3
      chmax(ans[0][i+1][3],max(ans[0][i][1]+cc,ans[0][i][2]+cc));
      //pri(ans[0][i+1][3]);
      //pri("-------------------");
    }
    aws += max(ans[0][mama][1],max(ans[0][mama][2],ans[0][mama][3]));
    //pri2("加点",max(ans[0][mama][1],max(ans[0][mama][2],ans[0][mama][3])));
  }
  pri(aws);

  return 0;
}


Measured memory_bytes: 3536