#include <stdio.h>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    int N, K, R, S, P;
    scanf("%d %d", &N, &K);
    char T[N + 1];
    scanf("%d %d %d", &R, &S, &P);
    scanf("%s", T);

    int points[N+1];
    int i;
    for(i=0;i<=N;i++) {
        points[i] = 0;
    }


    for(i=1;i<=N;i++) {
      if(i >= K && T[i-K-1] != 'x' && T[i-K-1] == T[i - 1]) {
        points[i] = points[i-1];
        if(T[i] == 'r') {
          T[i-1] = 'x';
        } else if(T[i-1] == 's') {
          T[i-1] = 'x';
        } else {
          T[i-1] = 'x';
        }
      } else {
        int point;
        if(T[i-1] == 'r') {
          point = P;
        } else if(T[i-1] == 's') {
          point = R;
        } else {
          point = S;
        }
        points[i] = points[i-1] + point;
      }
    }
    fprintf(stdout, "%d", points[N]);

    return 0;
}

