#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>
#include <assert.h>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define _GLIBCXX_DEBUG
using namespace std;
struct __INIT { __INIT() { cin.tie(nullptr); ios::sync_with_stdio(false); } } __init;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const int mod = 1000000007;

//固定長配列の大きさ（dp用）
template<typename TYPE,size_t SIZE>
size_t array_length(const TYPE(&)[SIZE])
{
    return SIZE;
}
//剰余計算
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
//組み合わせ(剰余付き)
//combination c(n)で初期化する必要がある。（nはCの左側の数）
struct combination {
    vector<mint> fact, ifact;
    combination(int n) :fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
//桁取得
ll getDigit(ll n) {07;
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
//ペア比較順序
typedef pair<ll, ll> pair_t;
bool PSecComp(const pair_t& a, const pair_t& b) {
	if (a.second == b.second)return  a.first > b.first;
	else {
		return a.second > b.second;
	}
}

int main() {
    ll n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    ll tlen = t.length();
    vector<vector<ll>>play(k, vector<ll>());
    auto convertC = [&](char c) {
        if (c == 'r')return 0;
        else if (c == 's')return 1;
        else return 2;
    };
    rep(i, tlen) {
        play[i % k].push_back(convertC(t[i]));
    }
    auto point = [&](ll kind) {
        if (kind == 0)return p;
        else if (kind == 1)return r;
        else return s;
    };
    ll ans = 0;
    vector<vector<ll>>dp(pow(10, 6), vector<ll>(2, -INF));
    for (ll i = 0; i < k; i++) {
        rep(qq, 2)dp[0][qq] = (qq == 1 ? point(play[i][0]) : 0);
        for (ll m = 1; m < play[i].size(); m++) {
           if (i >= 1) {
               dp[m][0] = -INF;
               dp[m][1] = -INF;
           }
            for (ll now = 0; now <= 1; now++) {
                for (ll pre = 0; pre <= 1;pre++) {
                    if ((play[i][m-1] == play[i][m])&&(now == 1 && pre == 1))continue;
                    else chmax(dp[m][now], dp[m - 1][pre] + (now == 1 ? point(play[i][m]) : 0));
                }
            }
        }
        ans += *max_element(all(dp[play[i].size()-1]));
    }
    cout << ans << endl;
}



Measured memory_bytes: 59856