#include<bits/stdc++.h>
using namespace std;
int n,k,t[255],ans;
bool b[100005];
char a[100005],win[255];
int main()
{
	scanf("%d%d%d%d%d%s",&n,&k,&t['r'],&t['s'],&t['p'],a);
	win['r']='p',win['s']='r',win['p']='s';
	for(int i=0;i<n;i++){
		if(i<k) ans+=t[win[a[i]]],b[i]=1;
		else if(!b[i-k]||win[a[i-k]]!=win[a[i]]) ans+=t[win[a[i]]],b[i]=1;
	}
	printf("%d\n",ans);
}