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

int main()
{
	int n, k, r, s, p;
	string t;
	cin >> n >> k;
	cin >> r >> s >> p;
	cin >> t;

	long long ret = 0;
	for (int i = 0; i < n; ++i) {
		int point = 0;
		if (t[i] == 'r') {
			point = p;
		}
		else if (t[i] == 's') {
			point = r;
		}
		else {	// p
			point = s;
		}

		if (0 <= i - k && t[i] == t[i - k]) {
			point = 0;
			t[i] = 'n';
		}
		ret += point;
	}

	cout << ret << endl;

	return 0;
}