// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <string>

#include <vector>

#include <algorithm>

#include <functional>

#include <iomanip>

#include <stdlib.h>

#include <string.h>

#include <cstring>

#include <cmath>

#include <map>

#include <queue>

#include <deque>

#include <stack>

#include <set>

#include <stdio.h>

#include <tuple>

#include <bitset>

#include <cfloat>

#include <fstream>

#include <limits.h>

#include <list>

#include <math.h>

#include <random>

#include <unordered_map>

#include <unordered_set>

#include <bitset>

#include <numeric>

#include <utility>

#include <sstream>



template<class T> inline bool chmin(T& a, T b) {

	if (a > b) {

		a = b;

		return true;

	}

	return false;

}

template<class T> inline bool chmax(T& a, T b) {

	if (a < b) {

		a = b;

		return true;

	}

	return false;

}



using namespace std;

#define int long long

#define ll long long

#define rep(i, n) for (ll i = 0; i < (n); i++)

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)

#define repr(i,n) for(ll i=n;i>=0;i--)

#define P pair<ll, ll>

#define sz(x) (ll)x.size()

#define ALL(x) (x).begin(),(x).end()

#define ALLR(x) (x).rbegin(),(x).rend()

#define VE vector<ll>

#define COUT(x) cout<<(x)<<endl

#define MA map<ll,ll>

#define SE set<ll>

#define PQ priority_queue<ll>

#define PQR priority_queue<ll,VE,greater<ll>>

#define COUT(x) cout<<(x)<<endl

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl

#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define EPS (1e-10)

ll gcd(ll a, ll b) {

	if (a < b)swap(a, b);

	if (b == 0) return a;

	return gcd(b, a % b);

}

ll lcm(ll a, ll b) {

	ll g = gcd(a, b);

	return a / g * b;

}

bool prime(ll n) {

	for (ll i = 2; i <= sqrt(n); i++) {

		if (n%i == 0)return false;

	}

	return n != 1;

}





const long long MOD = 1000000007;

const long long INF = 1LL << 60;





const int MAX_N = 100010;

int a[100010][3];

int te[100010];

// dp[i][j]:i番目にjの手を出した時の点数の最大値

int dp[100010][3];

signed main() {

	ios_base::sync_with_stdio(0);

	cin.tie(0);

	int n, K; cin >> n >> K;

	int r, s, p; cin >> r >> s >> p;

	string t; cin >> t;

	rep(i, n) {

		if (t[i] == 's') {

			a[i][0] = r;

		}

		else if (t[i] == 'p') {

			a[i][1] = s;

		}

		else {

			a[i][2] = p;

		}

	}

	rep(i, 100010)te[i] = -1;

	rep(i, n) {

		rep(j, 3) {

			rep(k, 3) {

				if (i-K >= 0 &&k == te[i-K])continue;

				if (a[i][k] != 0) {

					te[i] = k;

				}

				if (dp[i + 1][k] < dp[i][j] + a[i][k]) {

					dp[i + 1][k] = dp[i][j] + a[i][k];

				}

			}

		}

	}

	int ans = 0;

	for (int i = 0; i < 3; i++) {

		chmax(ans, dp[n][i]);

	}

	cout << ans << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <cstdio>

#include <string>

#include <vector>

#include <algorithm>

#include <functional>

#include <iomanip>

#include <stdlib.h>

#include <string.h>

#include <cstring>

#include <cmath>

#include <map>

#include <queue>

#include <deque>

#include <stack>

#include <set>

#include <stdio.h>

#include <tuple>

#include <bitset>

#include <cfloat>

#include <fstream>

#include <limits.h>

#include <list>

#include <math.h>

#include <random>

#include <unordered_map>

#include <unordered_set>

#include <bitset>

#include <numeric>

#include <utility>

#include <sstream>



template<class T> inline bool chmin(T& a, T b) {

	if (a > b) {

		a = b;

		return true;

	}

	return false;

}

template<class T> inline bool chmax(T& a, T b) {

	if (a < b) {

		a = b;

		return true;

	}

	return false;

}



using namespace std;

#define int long long

#define ll long long

#define rep(i, n) for (ll i = 0; i < (n); i++)

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)

#define repr(i,n) for(ll i=n;i>=0;i--)

#define P pair<ll, ll>

#define sz(x) (ll)x.size()

#define ALL(x) (x).begin(),(x).end()

#define ALLR(x) (x).rbegin(),(x).rend()

#define VE vector<ll>

#define COUT(x) cout<<(x)<<endl

#define MA map<ll,ll>

#define SE set<ll>

#define PQ priority_queue<ll>

#define PQR priority_queue<ll,VE,greater<ll>>

#define COUT(x) cout<<(x)<<endl

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl

#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define EPS (1e-10)

#define pb push_back



const long long MOD = 1000000007;

//const long long MOD = 998244353;

const long long INF = 1LL << 60;

const double PI = acos(-1.0);





long long modinv(long long a, long long m) {

	long long b = m, u = 1, v = 0;

	while (b) {

		long long t = a / b;

		a -= t * b; swap(a, b);

		u -= t * v; swap(u, v);

	}

	u %= m;

	if (u < 0) u += m;

	return u;

}

ll gcd(ll a, ll b) {

	if (a < b)swap(a, b);

	if (b == 0) return a;

	unsigned r;

	while ((r = a % b)) {

		a = b;

		b = r;

	}

	return b;

}

ll lcm(ll a, ll b) {

	ll g = gcd(a, b);

	return a * b / g;

}

bool prime(ll n) {

	for (ll i = 2; i <= sqrt(n); i++) {

		if (n%i == 0)return false;

	}

	return n != 1;

}

map<ll, ll> prime_factor(ll n) {

	map<ll, ll> ret;

	for (ll i = 2; i * i <= n; i++) {

		while (n % i == 0) {

			ret[i]++;

			n /= i;

		}

	}

	if (n != 1) ret[n] = 1;

	return ret;

}







const int MAX_N = 100010;







signed main() {

	ios_base::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);

	int n, k; cin >> n >> k;

	int r, s, p; cin >> r >> s >> p;

	string t; cin >> t;

	string tmp = "";

	int ans = 0;

	rep(i, n) {

		if (i < k) {

			if (t[i] == 'r') {

				ans += p; tmp += 'p';

			}

			else if (t[i] == 's') {

				ans += r; tmp += 'r';

			}

			else {

				ans += s; tmp += 's';

			}

		}

		else {

			if (t[i] == 'r') {

				if (tmp[i - k] == 'p') {

					tmp += '?';

				}

				else {

					ans += p; tmp += 'p';

				}

			}

			else if (t[i] == 's') {

				if (tmp[i - k] == 'r') {

					tmp += '?';

				}

				else {

					ans += r; tmp += 'r';

				}

			}

			else {

				if (tmp[i - k] == 's') {

					tmp += '?';

				}

				else {

					ans += s; tmp += 's';

				}

			}

		}

		

	}

	cout << ans << endl;

	return 0;

}

// Fastest known solution for this problem: