#include<bits/stdc++.h>
using namespace std;
int n,k,r,s,p,f[200010],ans;
string t;
int main(){
	cin>>n>>k>>r>>s>>p>>t;
	for (int i=0;i<n;i++)
		if (t[i]=='r'){
			if (f[i]==3)
				continue;
			else{
				f[i+k]=3;
				ans+=p;
			}
		}
		else if (t[i]=='s'){
			if (f[i]==1)
				continue;
			else{
				f[i+k]=1;
				ans+=r;
			}
		}
		else if (t[i]=='p'){
			if (f[i]==2)
				continue;
			else{
				f[i+k]=2;
				ans+=s;
			}
		}
	cout<<ans<<endl;
	return 0;
}