#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,r,s,p;
  cin>>n>>k>>r>>s>>p;
  map<char,int> h;
  h['r']=p;
  h['s']=r;
  h['p']=s;
  string t;
  cin>>t;
  int w=0;
  for(int i=0;i<k;i++)
    w+=h.at(t.at(i));
  vector<bool> d(k);
  for(int i=k;i<n;i++){
    if(t.at(i)==t.at(i-k)){
      if(d.at(i%k))
        w+=h.at(t.at(i));
      d.at(i%k)=!d.at(i%k);
    }
    else{
      w+=h.at(t.at(i));
      d.at(i%k)=0;
    }
  }
  cout<<w<<endl;
}