#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

struct edge{
    ll to;
    ll cost;
    edge(ll t, ll c){
        to = t;
        cost = c;
    }
};

//* dijkstra algorithm with adjacency list
void dijkstra(vector<vector<edge> > &G, vll &dist, ll s){
    fill(dist.begin(), dist.end(), INF);
    priority_queue<pll, vector<pll>, greater<pll> > que;
    dist[s] = 0;
    que.push(pll(0, s));
    while(!que.empty()){
        ll score = que.top().first;
        ll u = que.top().second;
        que.pop();
        for(ll i=0; i< G[u].size(); i++){
            edge e = G[u][i];
            if(dist[e.to] > score + e.cost){
                dist[e.to] = score + e.cost;
                que.push(pll(dist[e.to], e.to));
            }
        }
    }
    return;
}

ll getSub(ll R, ll S, ll P, string Tsm){
    if(Tsm.empty()){
        return 0;
    }
    ll n = Tsm.length();
    vector<vector<edge> > G(3*n+1);
    ll M = max(R, max(S, P));
    R = M-R; S = M-S; P = M-P;
    if(Tsm[0]== 'r'){ //* only P 
        G[0].push_back(edge(1, M));
        G[0].push_back(edge(2, M));
        G[0].push_back(edge(3, P));
    }
    else if(Tsm[0]=='s'){ //* only R
        G[0].push_back(edge(1, R));
        G[0].push_back(edge(2, M));
        G[0].push_back(edge(3, M));
    }
    else{ //* Tsm[i+1]=='p' , only S
        G[0].push_back(edge(1, M));
        G[0].push_back(edge(2, S));
        G[0].push_back(edge(3, M));
    }

    for(ll i=0; i<n-1; i++){
        if(Tsm[i+1]== 'r'){ //* only P 
            G[i*3+1].push_back(edge(i*3+5, M));
            G[i*3+1].push_back(edge(i*3+6, P));
            G[i*3+2].push_back(edge(i*3+4, M));
            G[i*3+2].push_back(edge(i*3+6, P));
            G[i*3+3].push_back(edge(i*3+4, M));
            G[i*3+3].push_back(edge(i*3+5, M));
        }

        else if(Tsm[i+1]=='s'){ //* only R
            G[i*3+1].push_back(edge(i*3+5, M));
            G[i*3+1].push_back(edge(i*3+6, M));
            G[i*3+2].push_back(edge(i*3+4, R));
            G[i*3+2].push_back(edge(i*3+6, M));
            G[i*3+3].push_back(edge(i*3+4, R));
            G[i*3+3].push_back(edge(i*3+5, M));
        }
        else{ //* Tsm[i+1]=='p' , only S
            G[i*3+1].push_back(edge(i*3+5, S));
            G[i*3+1].push_back(edge(i*3+6, M));
            G[i*3+2].push_back(edge(i*3+4, M));
            G[i*3+2].push_back(edge(i*3+6, M));
            G[i*3+3].push_back(edge(i*3+4, M));
            G[i*3+3].push_back(edge(i*3+5, S));
        }
    }
    vll dist(3*n+1);
    dijkstra(G, dist, 0);
    ll res = dist[3*n-2];
    res = min(res, dist[3*n-1]); res = min(res, dist[3*n]); 
    return (n*M-res);
}

void solve(long long N, long long K, long long R, long long S, long long P, std::string T){
    ll ans = 0;
    REP(i, K){
        string Tsm;
        for(ll j=i; j< N; j+=K){
            Tsm.push_back(T[j]);
        }
        ll tmp = getSub(R, S, P, Tsm);
        ans += tmp;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long R;
    scanf("%lld",&R);
    long long S;
    scanf("%lld",&S);
    long long P;
    scanf("%lld",&P);
    std::string T;
    std::cin >> T;
    solve(N, K, R, S, P, T);
    return 0;
}


Measured memory_bytes: 23808