#include <bits/stdc++.h>
#define ll long long
using namespace std;
int janten(int r, int s, int p, char rsp){
  
  if (rsp =='r'){return p;}
  if (rsp == 'p'){return s;}
  if (rsp == 's'){return r;}
}

int main() {
  int n,k,r,s,p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;

  int ten = 0;

  for (int i = 0; i < n; i++){
    if (i >= k && t.at(i-k) == t.at(i)){
      ten = ten;
      t.at(i)='h';}
    else{ten += janten(r,s,p,t.at(i)); }
  }
  cout << ten;
  }

