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

int main() {
  int N,K;
  cin>>N>>K;
  int R,S,P;
  cin>>R>>S>>P;
  string T;
  cin>>T;
  vector<int> a(N);
  int answer=0;
  for(int i=0;i<N;i++){
    if(i-K>=0&&T[i-K]==T[i]&&a[i-K]!=0)
      a[i]=0;
    else if(T[i]=='r')
      a[i]=P;
    else if(T[i]=='s')
      a[i]=R;
    else if(T[i]=='p')
      a[i]=S;
  }
  for(int i=0;i<N;i++){
    answer+=a[i];
  }
  cout<<answer;
}