// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

// #include <bits/extc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> // tree
// #include <ext/pb_ds/hash_policy.hpp> // hash
// #include <ext/pb_ds/trie_policy.hpp> // trie
// #include <ext/pb_ds/priority_queue.hpp> // priority_queue
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define X first
#define Y second
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define Push push_back

using lli = long long;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
using Double = long double;
template<typename T>
using Vector = vector<vector<T>>;
template<typename T>
using Prior = priority_queue<T>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;

const lli mod = 1E9 + 7;
const Double PI = 3.1415926535846;
const Double eps = 1e-8;

lli fastPow(lli, lli, lli);
bool millerRabin(lli, lli);
bool MR_PrimeFilter(lli);
template<size_t rows, size_t cols>
void MatrixMul(lli (&a)[rows][cols], lli b[rows][cols]);

void solve() {
	lli n, k, c[3];
	string t;
	cin >> n >> k >> c[0] >> c[1] >> c[2] >> t;
	
	for (auto &x : t) {
		if (x == 'r') x = '2';
		if (x == 's') x = '0';
		if (x == 'p') x = '1';
	}
	
	lli dp[n / k + 5][3], ANS = 0;
	for (int i = 0; i < k; ++i) {
		memset(dp, 0, sizeof(dp));
		dp[0][t[i] - '0'] = c[t[i] - '0'];
		lli ans = c[t[i] - '0'];
		
		for (int j = i+k, tok = 1; j < n; j += k, ++tok) {
			dp[tok][0] = max(dp[tok - 1][1], dp[tok - 1][2]) + (t[j] == '0') * c[0];
			dp[tok][1] = max(dp[tok - 1][0], dp[tok - 1][2]) + (t[j] == '1') * c[1];
			dp[tok][2] = max(dp[tok - 1][0], dp[tok - 1][1]) + (t[j] == '2') * c[2];
			ans = max({ans, dp[tok][0], dp[tok][1], dp[tok][2]});
		}
		
		// cout << ans << ", ";
		ANS += ans;
	}
	
	cout << ANS << "\n";
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

///                              ///
/// BELOW ARE TEMPLATE FUNCTIONS ///
///                              ///

lli fastPow(lli base, lli exp, lli module = mod) {
	lli ans = 1;
	base %= module;
	while (exp) {
		if (exp & 1) ans = ans * base % module;
		base = base * base % module;
		exp >>= 1;
	}
	return ans;
}

bool millerRabin(lli n, lli a) {
	/*
	 * n < 4,759,123,141		3 : {2, 7, 61}
	 * n < 1,122,004,669,633	4 : {2, 13, 23, 1662803}
	 * n < 3,474,749,660,383	6 : {p in [2, 13]}
	 * n < 2^64					7 : 
	 * {2, 325, 9375, 28178, 450775, 9780504, 1795265022}
	 *
	 * else, random everytime gives a 75% of correction
	 */
	
	if (n < 2) return 0;
	if ((a = a%n) == 0) return 1;
	if (n & 1 ^ 1) return n == 2;
	
	lli lowb = (n - 1) & -(n - 1);
	lli tmp = (n - 1) / lowb; // lowbit of (n-1)
	lli t = __lg(lowb);
	lli x = 1;
	
	for (; tmp; tmp /= 2, a = a*a%n) {
		if (tmp & 1) x = x * a % n;
	}
	
	if (x == 1 or x == n - 1) return 1;
	
	while (--t) {
		if ((x = x*x%n) == n - 1) return 1;
	}
	
	return 0;
}

bool MR_PrimeFilter(lli n) {
	vector<lli> v[4];
	v[0] = {2, 7, 61};
	v[1] = {2, 13, 23, 1662803};
	v[2] = {2, 3, 5, 7, 11, 13};
	v[3] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
	
	if (n < 4759123141LL) {
		for (lli x : v[0]) {
			if (!millerRabin(n, x)) return false;
		}
		return true;
	}
	if (n < 1122004669633LL) {
		for (lli x : v[1]) {
			if (!millerRabin(n, x)) return false;
		}
		return true;
	}
	if (n < 3474749660383LL) {
		for (lli x : v[2]) {
			if (!millerRabin(n, x)) return false;
		}
		return true;
	}
	for (lli x : v[3]) {
		if (!millerRabin(n, x)) return false;
	}
	return true;
}

template<size_t rows, size_t cols>
void MatrixMul(lli (&a)[rows][cols], lli b[rows][cols]) {
	lli c[rows][cols];
	memset(c, 0, sizeof(c));
	
	for (int i = 0; i < rows; ++i) {
		for (int j = 0; j < rows; ++j) {
			for (int k = 0; k < rows; ++k) {
				c[i][j] += a[i][k] * b[k][j];
				c[i][j] %= mod;
			}
		}
	}
	
	for (int i = 0; i < rows; ++i) {
		for (int j = 0; j < cols; ++j) {
			a[i][j] = c[i][j];
		}
	}
}

Measured memory_bytes: 2816