n, k = list(map(int, input().split()))

r, s, p = list(map(int, input().split()))



t = str(eval(input()))



t_ = ''

ans = 0

for i in range(n):

    if i < k:

        if t[i] == 'r':

            t_ += 'p'

            ans += p

        elif t[i] == 's':

            t_ += 'r'

            ans += r

        else:

            t_ += 's'

            ans += s

    elif i+k <= n-1:

        if t[i] == 'r':

            if t_[i-k] != 'p':

                t_ += 'p'

                ans += p

            else:

                if t[i+k] == 'p':

                    t_ += 'r'

                else:

                    t_ += 's'

        elif t[i] == 's':

            if t_[i-k] != 'r':

                t_ += 'r'

                ans += r

            else:

                if t[i+k] == 'p':

                    t_ += 'p'

                else:

                    t_ += 's'

        else:

            if t_[i-k] != 's':

                t_ += 's'

                ans += s

            else:

                if t[i+k] == 's':

                    t_ += 'p'

                else:

                    t_ += 'r'

    else:

        if t[i] == 'r':

            if t_[i-k] != 'p':

                t_ += 'p'

                ans += p

            else:

                if t[i-k] == 'r':

                    t_ += 's'

                else:

                    t_ += 'r'

        elif t[i] == 's':

            if t_[i-k] != 'r':

                t_ += 'r'

                ans += r

            else:

                if t[i-k] == 'p':

                    t_ += 's'

                else:

                    t_ += 'p'

        else:

            if t_[i-k] != 's':

                t_ += 's'

                ans += s

            else:

                if t[i-k] == 'r':

                    t_ += 'p'

                else:

                    t_ += 'r'

print(ans)

#print(t_)

n, k = list(map(int, input().split()))

r, s, p = list(map(int, input().split()))

t = str(eval(input()))



ans = 0

temp = [0]*n

for i in range(n):

    if i <= k-1:

        if t[i] == 'r':

            ans += p

        elif t[i] == 's':

            ans += r

        else:

            ans += s

    else:

        if t[i-k] == t[i]:

            if temp[i-k] == 0:

                temp[i] = -1

            else:

                if t[i] == 'r':

                    ans += p

                elif t[i] == 's':

                    ans += r

                else:

                    ans += s

                temp[i] = 0

        else:

            if t[i] == 'r':

                ans += p

            elif t[i] == 's':

                ans += r

            else:

                ans += s

            temp[i] = 0



    #print(i, ans)

print(ans)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = str(eval(input()))
t_ = ""
ans = 0
for i in range(n):
    if i < k:
        if t[i] == "r":
            t_ += "p"
            ans += p
        elif t[i] == "s":
            t_ += "r"
            ans += r
        else:
            t_ += "s"
            ans += s
    elif i + k <= n - 1:
        if t[i] == "r":
            if t_[i - k] != "p":
                t_ += "p"
                ans += p
            else:
                if t[i + k] == "p":
                    t_ += "r"
                else:
                    t_ += "s"
        elif t[i] == "s":
            if t_[i - k] != "r":
                t_ += "r"
                ans += r
            else:
                if t[i + k] == "p":
                    t_ += "p"
                else:
                    t_ += "s"
        else:
            if t_[i - k] != "s":
                t_ += "s"
                ans += s
            else:
                if t[i + k] == "s":
                    t_ += "p"
                else:
                    t_ += "r"
    else:
        if t[i] == "r":
            if t_[i - k] != "p":
                t_ += "p"
                ans += p
            else:
                if t[i - k] == "r":
                    t_ += "s"
                else:
                    t_ += "r"
        elif t[i] == "s":
            if t_[i - k] != "r":
                t_ += "r"
                ans += r
            else:
                if t[i - k] == "p":
                    t_ += "s"
                else:
                    t_ += "p"
        else:
            if t_[i - k] != "s":
                t_ += "s"
                ans += s
            else:
                if t[i - k] == "r":
                    t_ += "p"
                else:
                    t_ += "r"
print(ans)
# print(t_)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = str(eval(input()))
ans = 0
temp = [0] * n
for i in range(n):
    if i <= k - 1:
        if t[i] == "r":
            ans += p
        elif t[i] == "s":
            ans += r
        else:
            ans += s
    else:
        if t[i - k] == t[i]:
            if temp[i - k] == 0:
                temp[i] = -1
            else:
                if t[i] == "r":
                    ans += p
                elif t[i] == "s":
                    ans += r
                else:
                    ans += s
                temp[i] = 0
        else:
            if t[i] == "r":
                ans += p
            elif t[i] == "s":
                ans += r
            else:
                ans += s
            temp[i] = 0
    # print(i, ans)
print(ans)

-t_ = "" +temp = [0] * n -    if i < k: +    if i <= k - 1: -            t_ += "p" -            t_ += "r" -            t_ += "s" -    elif i + k <= n - 1: -        if t[i] == "r": -            if t_[i - k] != "p": -                t_ += "p" +    else: +        if t[i - k] == t[i]: +            if temp[i - k] == 0: +                temp[i] = -1 +            else: +                if t[i] == "r": +                    ans += p +                elif t[i] == "s": +                    ans += r +                else: +                    ans += s +                temp[i] = 0 +        else: +            if t[i] == "r": -            else: -                if t[i + k] == "p": -                    t_ += "r" -                else: -                    t_ += "s" -        elif t[i] == "s": -            if t_[i - k] != "r": -                t_ += "r" +            elif t[i] == "s": -                if t[i + k] == "p": -                    t_ += "p" -                else: -                    t_ += "s" -        else: -            if t_[i - k] != "s": -                t_ += "s" -            else: -                if t[i + k] == "s": -                    t_ += "p" -                else: -                    t_ += "r" -    else: -        if t[i] == "r": -            if t_[i - k] != "p": -                t_ += "p" -                ans += p -            else: -                if t[i - k] == "r": -                    t_ += "s" -                else: -                    t_ += "r" -        elif t[i] == "s": -            if t_[i - k] != "r": -                t_ += "r" -                ans += r -            else: -                if t[i - k] == "p": -                    t_ += "s" -                else: -                    t_ += "p" -        else: -            if t_[i - k] != "s": -                t_ += "s" -                ans += s -            else: -                if t[i - k] == "r": -                    t_ += "p" -                else: -                    t_ += "r" +            temp[i] = 0 +    # print(i, ans) -# print(t_)