#include<bits/stdc++.h>
using namespace std;

int memo[100000][3];
// {0,1,2}={r,s,p}
int main(){
	int n,k,r,s,p;	cin>>n>>k>>r>>s>>p;
	string t;	cin>>t;

	for(int i=0; i+k<n; i++){
		if(t[i]==t[i+k]){
			t[i+k]='_';
		}
	}
	//cout<<t<<endl;
	int ans=0;
	for(int i=0;i<n;i++){
		if(t[i]=='r')ans+=p;
		else if(t[i]=='s')ans+=r;
		else if(t[i]=='p')ans+=s;
	}

	cout<<ans<<endl;

	return 0;
}
