N, K = list(map(int, input().split()))

R, S, P = list(map(int, input().split()))

T = eval(input())



def get_point(s):

  if s == "r":

    return P

  elif s == "s":

    return R

  elif s == "p":

    return S



ans = 0

restricted = [False] * N

for i in range(N):

  if (i+1) <= K:

    ans += get_point(T[i])

  else:

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

      if restricted[i-K]:

        ans += get_point(T[i])

      else:

        restricted[i] = True

    else:

      ans += get_point(T[i])



print(ans)

import sys

input = sys.stdin.readline





def main():

    N, K = list(map(int, input().split()))

    R, S, P = list(map(int, input().split()))

    T = input().rstrip()



    n_win = {"r": 0, "s": 0, "p": 0}

    lock = [False] * N

    for i in range(K):

        n_win[T[i]] += 1

        lock[i] = True

    for i in range(K, N):

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

            if not lock[i-K]:

                n_win[T[i]] += 1

                lock[i] = True

        else:

            n_win[T[i]] += 1

            lock[i] = True



    ans = R * n_win["s"] + S * n_win["p"] + P * n_win["r"]

    print(ans)





if __name__ == "__main__":

    main()

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())


def get_point(s):
    if s == "r":
        return P
    elif s == "s":
        return R
    elif s == "p":
        return S


ans = 0
restricted = [False] * N
for i in range(N):
    if (i + 1) <= K:
        ans += get_point(T[i])
    else:
        if T[i - K] == T[i]:
            if restricted[i - K]:
                ans += get_point(T[i])
            else:
                restricted[i] = True
        else:
            ans += get_point(T[i])
print(ans)

import sys

input = sys.stdin.readline


def main():
    N, K = list(map(int, input().split()))
    R, S, P = list(map(int, input().split()))
    T = input().rstrip()
    n_win = {"r": 0, "s": 0, "p": 0}
    lock = [False] * N
    for i in range(K):
        n_win[T[i]] += 1
        lock[i] = True
    for i in range(K, N):
        if T[i - K] == T[i]:
            if not lock[i - K]:
                n_win[T[i]] += 1
                lock[i] = True
        else:
            n_win[T[i]] += 1
            lock[i] = True
    ans = R * n_win["s"] + S * n_win["p"] + P * n_win["r"]
    print(ans)


if __name__ == "__main__":
    main()

-N, K = list(map(int, input().split())) -R, S, P = list(map(int, input().split())) -T = eval(input()) +import sys + +input = sys.stdin.readline -def get_point(s): -    if s == "r": -        return P -    elif s == "s": -        return R -    elif s == "p": -        return S +def main(): +    N, K = list(map(int, input().split())) +    R, S, P = list(map(int, input().split())) +    T = input().rstrip() +    n_win = {"r": 0, "s": 0, "p": 0} +    lock = [False] * N +    for i in range(K): +        n_win[T[i]] += 1 +        lock[i] = True +    for i in range(K, N): +        if T[i - K] == T[i]: +            if not lock[i - K]: +                n_win[T[i]] += 1 +                lock[i] = True +        else: +            n_win[T[i]] += 1 +            lock[i] = True +    ans = R * n_win["s"] + S * n_win["p"] + P * n_win["r"] +    print(ans) -ans = 0 -restricted = [False] * N -for i in range(N): -    if (i + 1) <= K: -        ans += get_point(T[i]) -    else: -        if T[i - K] == T[i]: -            if restricted[i - K]: -                ans += get_point(T[i]) -            else: -                restricted[i] = True -        else: -            ans += get_point(T[i]) -print(ans) +if __name__ == "__main__": +    main()