#!/usr/bin/env python3

import sys





def solve(N: int, K: int, R: int, S: int, P: int, T: str):

    ans=0

    flag=[False]*N

    for i in range(N):

        if i<K:

            ans+=P if T[i]=='r' else S if T[i]=='p' else R

            flag[i]=True

    for i in range(K, N):

        if T[i]!=T[i-K] or (not flag[i-K]):

            ans+=P if T[i]=='r' else S if T[i]=='p' else R

            flag[i]=True

        

    print(ans)



    return





# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    K = int(next(tokens))  # type: int

    R = int(next(tokens))  # type: int

    S = int(next(tokens))  # type: int

    P = int(next(tokens))  # type: int

    T = next(tokens)  # type: str

    solve(N, K, R, S, P, T)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3

import sys





def solve(N: int, K: int, R: int, S: int, P: int, T: str):

    ans=0

    flag=[False]*N

    for i in range(N):

        if i<K or T[i]!=T[i-K] or (not flag[i-K]):

            ans+=P if T[i]=='r' else S if T[i]=='p' else R

            flag[i]=True

        

    print(ans)



    return





# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    K = int(next(tokens))  # type: int

    R = int(next(tokens))  # type: int

    S = int(next(tokens))  # type: int

    P = int(next(tokens))  # type: int

    T = next(tokens)  # type: str

    solve(N, K, R, S, P, T)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3
import sys


def solve(N: int, K: int, R: int, S: int, P: int, T: str):
    ans = 0
    flag = [False] * N
    for i in range(N):
        if i < K:
            ans += P if T[i] == "r" else S if T[i] == "p" else R
            flag[i] = True
    for i in range(K, N):
        if T[i] != T[i - K] or (not flag[i - K]):
            ans += P if T[i] == "r" else S if T[i] == "p" else R
            flag[i] = True
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    T = next(tokens)  # type: str
    solve(N, K, R, S, P, T)


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys


def solve(N: int, K: int, R: int, S: int, P: int, T: str):
    ans = 0
    flag = [False] * N
    for i in range(N):
        if i < K or T[i] != T[i - K] or (not flag[i - K]):
            ans += P if T[i] == "r" else S if T[i] == "p" else R
            flag[i] = True
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    T = next(tokens)  # type: str
    solve(N, K, R, S, P, T)


if __name__ == "__main__":
    main()

-        if i < K: -            ans += P if T[i] == "r" else S if T[i] == "p" else R -            flag[i] = True -    for i in range(K, N): -        if T[i] != T[i - K] or (not flag[i - K]): +        if i < K or T[i] != T[i - K] or (not flag[i - K]):