#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define li long
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define cd complex<double>
const int N = 10000000;
vector<int> bit(N+2,0);
int next(int x)
{
    return x+(x&(-x));
}
int par(int x)
{
    return x-(x&(-x));
}
void update(int x,int val,int n)
{
    while(x<n)
    {
        bit[x]+=val;
        x = next(x);
    }
}
void bitify(vector<int> &a,int n)
{
    for(int i = 1; i<=n; i++)
    {
        update(i,a[i-1],n);
    }
}

int getsum(int x)
{
    int sum = 0;
    while(x>0)
    {
        sum+=bit[x];
        x = par(x);
    }
    return sum;
}
int rsum(int a,int b)
{
    return getsum(b)-getsum(a-1);
}
void optimize()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int power(int x, int y)
{
   int res = 1;

    //x = x % p;

    while (y > 0)
    {

        if (y & 1)
            res = (res*x) ;


        y = y>>1;
        x = (x*x) ;
    }
    return res;
}

//const int N = 10000000;
int lp[N+1];
unordered_set<int> st;
vector<int> pr;
void solve(){
for (int i=2; i<=N; ++i) {
    if (lp[i] == 0) {
        lp[i] = i;
        st.insert(i);
        pr.push_back(i);
    }
    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
        lp[i * pr[j]] = pr[j];
}
}
class TrieNode
{
public:

    TrieNode* left;
    TrieNode* right;
    TrieNode()
    {
        left = NULL;
        right = NULL;
    }
};
void insert(TrieNode* head,int x)
{
    TrieNode* curr = head;
    for(int i = 31; i>=0; i--)
    {
        int b = (x>>i)&1;
        if(b == 0)
        {
            if(!curr->left)curr->left = new TrieNode();
            curr = curr->left;
        }
        else
        {
            if(!curr->right)curr->right = new TrieNode();
            curr = curr->right;
        }
    }
}
int maxXorVal(TrieNode* head,vector<int> &arr,int n)
{
    int max_xor = INT_MIN;
    for(int i = 0; i<n; i++)
    {
        int val = arr[i];
        TrieNode* curr = head;
        int curr_xor = 0;
        for(int j = 31; j>=0; j--)
        {
            int b = (val>>j)&1;
            if(b == 0)
            {
                if(curr->right)curr = curr->right,curr_xor+=power(2,j);
                else curr = curr->left;
            }
            else
            {
                if(curr->left)curr = curr->left,curr_xor += power(2,j);
                else curr = curr->right;
            }
        }
        max_xor = max(max_xor,curr_xor);
    }
    return max_xor;
}

void test_case()
{
    ll n,k,r,s,p,score = 0;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    vector<char> poss(n,'#');
    for(int i = 0; i<k; i++)
    {
        if(t[i] == 'r')
        {
            score+=p;
            poss[i] = 'p';
        }
        else if(t[i] == 'p')
        {
            score+=s;
            poss[i] = 's';
        }
        else
        {
            score+=r;
            poss[i] = 'r';
        }
    }
    for(int i = k; i<(int)t.size(); i++)
    {
         if(t[i] == 'r')
        {
            if(poss[i-k]!='p')
            {
                score+=p;
                poss[i] = 'p';
            }
        }
        else if(t[i] == 'p')
        {

            if(poss[i-k]!='s'){
                score+=s;
                poss[i] = 's';
            }
        }
        else
        {
            if(poss[i-k]!='r')
            {
                score+=r;
                poss[i] = 'r';
            }
        }
    }
    cout<<score;
}

int main()
{
	optimize();
	test_case();
}



Measured memory_bytes: 39552