#include <iostream>
using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  ll R, S, P; cin >> R >> S >> P;
  string T; cin >> T;

  ll ans = 0;
  rep(i, N) {
    if (i-K >= 0 && T[i] == T[i-K])
      T[i] = 0;

    if (T[i] == 'r')
      ans += P;
    if (T[i] == 's')
      ans += R;
    if (T[i] == 'p')
      ans += S;
  }
  cout << ans << endl;

  return 0;
}
