#include <iostream>
#include <string>

using namespace std;

long long dp[200005][3];

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

int main() {
	int n, k; cin >> n >> k;
	int rsp[3]; cin >> rsp[0] >> rsp[1] >> rsp[2];
	string t; cin >> t;
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		if (i < k) ans += rsp[sto(t[i])];
		else if (t[i - k] == t[i]) t[i] = '-';
		else ans += rsp[sto(t[i])];
	}
	cout << ans << endl;

	return 0;
}