// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <cstring>

#include <fstream>

#include <string>

#include <vector>

#include <map>

#include <set>

#define ll long long

#define ull unsigned long long

#define mod 1000000007



using namespace std;



int n, k, r, s, p;

ll dp[100005];

string t;



/*

	0 -> r

	1 -> s

	2 -> p

*/



/*ll solve(int pos, string S)

{

	if (pos == t.size()) return 0;

	if (dp[pos] != -1) return dp[pos];

	ll ans = 0;

	for (int i = 0; i < 3; i++)

	{

		if (pos <= k)

		{

			S.push_back(i + '0');

			if (t[pos] == 'r' && i == 2) ans = max(ans, p + solve(pos + 1, S));

			else if (t[pos] == 's' && i == 0) ans = max(ans, r + solve(pos + 1, S));

			else if (t[pos] == 'p' && i == 1)ans = max(ans, s + solve(pos + 1, S));

			else ans = max(ans, solve(pos + 1, S));

			S.pop_back();

		}

		else

		{

			if (S[pos - k] - '0' != i)

			{

				S.push_back(i + '0');

				if (t[pos] == 'r' && i == 2) ans = max(ans, p + solve(pos + 1, S));

				else if (t[pos] == 's' && i == 0) ans = max(ans, r + solve(pos + 1, S));

				else if (t[pos] == 'p' && i == 1)ans = max(ans, s + solve(pos + 1, S));

				else ans = max(ans, solve(pos + 1, S));

				S.pop_back();

			}

		}

	}

	return dp[pos] = ans;

}*/



int main()

{

	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	memset(dp, -1, sizeof dp);

	cin >> n >> k >> r >> s >> p >> t;

	//t = '*' + t;

	//cout << solve(1, "*") << '\n';

	ll ans = 0;

	for (int i = 0; i < n; i++)

	{

		if (i < k || t[i] != t[i - k])

		{

			if (t[i] == 'r')

			{

				ans += p;

			}

			else if (t[i] == 's')

			{

				ans += r;

			}

			else

			{

				ans += s;

			}

		}

		else t[i] = 'z';

	}

	cout << ans << '\n';

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define fv            first

#define sv            second

#define ll            long long

#define pb            push_back

#define mp            make_pair

#define pll           pair<ll,ll>

#define pii           pair<int,int>

#define READ(x)       freopen(x,"r",stdin)

#define WRITE(x)      freopen(x,"w",stdout)

#define all(x)        (x).begin(),(x).end()

#define isWorking()   cout<<"Wroking"<<endl

#define FOR(i,x,y)    for(int i=x; i<y; i++)

#define PRINT(ok)     cout<<(ok? "YES":"NO")<<endl

#define SetPrint(a,x) cout<<fixed<<setprecision(x)<<a<<endl

#define Fast_Input    ios_base :: sync_with_stdio(0),cin.tie(0);



const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;

int testCase=1,cas=0;



int main() {

    Fast_Input



//    cin>>testCase;

    while(testCase--) {

        ll n,k; cin>>n>>k;

        ll r,s,p; cin>>r>>s>>p;



        string str; cin>>str;

        string comHand="1"; comHand+=str;

        ll ans=0;



        for(int i=1; i<=n; i++){

            if(i<=k){

                if(comHand[i]=='r') ans+=p;

                else if(comHand[i]=='p') ans+=s;

                else    ans+=r;

                continue;

            }

            if(comHand[i]==comHand[i-k]) comHand[i]='1';

            else{

                if(comHand[i]=='r') ans+=p;

                else if(comHand[i]=='p') ans+=s;

                else    ans+=r;

            }

        }

        cout<<ans<<endl;

    }

    return 0;

}


// Fastest known solution for this problem: