/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long, long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")
#define debugOut(a, b) (std::cerr << "(" << (a) << "," << (b) << ")" << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

//ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll N, K, R, S, P;
string T;

int getRSP(char ch)
{
	switch (ch)
	{
	case 'r':
		return 0;
		break;

	case 's':
		return 1;
		break;

	case 'p':
		return 2;
		break;
	}

	return -1;
}

inline bool isWin(int myself, int enemy)
{
	return (myself + 1) % 3 == enemy;
}
inline bool isDraw(int myself, int enemy)
{
	return myself == enemy;
}
inline bool isLoss(int myself, int enemy)
{
	return myself == (enemy + 1) % 3;
}

int winPoint(int myself)
{
	switch (myself)
	{
	case 0:
		return R;
		break;

	case 1:
		return S;
		break;

	case 2:
		return P;
		break;
	}

	return -1;

}

void Main()
{
	cin >> N >> K >> R >> S >> P >> T;

	int time = divup(N, K);
	ll ret = 0;
	rep(i, K)
	{
		//debug_cout(i);

		vec<vec<ll>> dp(time + 1, vec<ll>(3, 0));
		ll end = 0;

		rep(j, time)
		{
			if (i + j * K >= N)	break;

			//debug_tabcout(1, j);

			int enemy = getRSP(T[i + j * K]);
			//debug_tabcout(2, enemy);

			rep(myself, 3)
			{
				rep(myself_b, 3)
				{
					if (myself == myself_b)	continue;

					if (isWin(myself, enemy))
					{
						chmax(dp[j + 1][myself], dp[j][myself_b] + winPoint(myself));
					}
					else
					{
						chmax(dp[j + 1][myself], dp[j][myself_b]);
					}
				}
			}

			end++;
		}

		debug_tabcout(1, end);

		/*rep(j, end + 1)
		{
			debug_tabcout(1, j);
			debug_tabcout(2, dp[j][0]);
			debug_tabcout(2, dp[j][1]);
			debug_tabcout(2, dp[j][2]);
		}*/

		ll max = 0;
		rep(j, 3)
		{
			chmax(max, dp[end][j]);
		}
		ret += max;
	}

	cout << ret;
}

/*****/

int main()
{
	//std::ios::sync_with_stdio(false);
	//std::cin.tie(0);

	//std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 5760