#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int n, k, r, s, p, cnt = 0;
	string t;
	cin >> n >> k;
	cin >> r >> s >> p;
	cin >> t;
	vector <int> A(t.length(), 0);

	for (int i = 0; i < n; i++) {
		if (i < k || !A[i-k] || t.substr(i, 1) != t.substr(i - k, 1)) {
			if (t.substr(i, 1) == "r") cnt += p;
			else if (t.substr(i, 1) == "s") cnt += r;
			else cnt += s;
			A[i] = 1;
		}
	}
	cout << cnt << endl;
	return 0;
}