def d_prediction_and_restriction():

    from itertools import groupby

    N, K = [int(i) for i in input().split()]

    R, S, P = [int(i) for i in input().split()]

    T = eval(input())



    ans = 0

    for i in range(K):

        tmp = groupby(T[i:N:K])

        for k, lst in tmp:

            v = len(list(lst))

            if v == 1:

                t = 1

            elif v % 2 == 0:

                t = v // 2

            else:

                t = v // 2 + 1

            if k == 'r':

                ans += P * t

            elif k == 's':

                ans += R * t

            elif k == 'p':

                ans += S * t

    return ans



print((d_prediction_and_restriction()))
def d_prediction_and_restriction():

    import re

    N, K = [int(i) for i in input().split()]

    R, S, P = [int(i) for i in input().split()]

    T = eval(input())



    can_win = {'r': 'p', 's': 'r', 'p': 's'}

    win_hand = [can_win[ch] for ch in T]

    points = {'r': R, 's': S, 'p': P}



    for i in range(K, N):

        if win_hand[i - K] == win_hand[i]:

            win_hand[i] = 'x'  # 制限に反するので手を適当に変える



    return sum(win_hand.count(ch) * points[ch] for ch in ('r', 's', 'p'))



print((d_prediction_and_restriction()))
def d_prediction_and_restriction():
    from itertools import groupby

    N, K = [int(i) for i in input().split()]
    R, S, P = [int(i) for i in input().split()]
    T = eval(input())
    ans = 0
    for i in range(K):
        tmp = groupby(T[i:N:K])
        for k, lst in tmp:
            v = len(list(lst))
            if v == 1:
                t = 1
            elif v % 2 == 0:
                t = v // 2
            else:
                t = v // 2 + 1
            if k == "r":
                ans += P * t
            elif k == "s":
                ans += R * t
            elif k == "p":
                ans += S * t
    return ans


print((d_prediction_and_restriction()))

def d_prediction_and_restriction():
    import re

    N, K = [int(i) for i in input().split()]
    R, S, P = [int(i) for i in input().split()]
    T = eval(input())
    can_win = {"r": "p", "s": "r", "p": "s"}
    win_hand = [can_win[ch] for ch in T]
    points = {"r": R, "s": S, "p": P}
    for i in range(K, N):
        if win_hand[i - K] == win_hand[i]:
            win_hand[i] = "x"  # 制限に反するので手を適当に変える
    return sum(win_hand.count(ch) * points[ch] for ch in ("r", "s", "p"))


print((d_prediction_and_restriction()))

-    from itertools import groupby +    import re -    ans = 0 -    for i in range(K): -        tmp = groupby(T[i:N:K]) -        for k, lst in tmp: -            v = len(list(lst)) -            if v == 1: -                t = 1 -            elif v % 2 == 0: -                t = v // 2 -            else: -                t = v // 2 + 1 -            if k == "r": -                ans += P * t -            elif k == "s": -                ans += R * t -            elif k == "p": -                ans += S * t -    return ans +    can_win = {"r": "p", "s": "r", "p": "s"} +    win_hand = [can_win[ch] for ch in T] +    points = {"r": R, "s": S, "p": P} +    for i in range(K, N): +        if win_hand[i - K] == win_hand[i]: +            win_hand[i] = "x"  # 制限に反するので手を適当に変える +    return sum(win_hand.count(ch) * points[ch] for ch in ("r", "s", "p"))