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

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

t=list(eval(input()))



# d={'r':0,'s':0,'p':0}

d={}

ans=0

c=0

for i in t:



    if c >= k:

        x =d[c-k]

        y = c+k

        if i =='r':

            if x == 'p':

                if  y < n and t[y] == 's':

                    d[c]='s'

                else:

                    d[c]='r'

            else:

                ans += p ; d[c]='p'

        elif i == 's': 

            if x == 'r':

               if y < n and t[y] == 'p' :

                    d[c]='p'

               else:

                    d[c]='s'

            else:

                ans += r;d[c]='r'

        elif i == 'p': 

            if x == 's':

               if  y < n and t[y] == 'r':

                    d[c]='r'

               else:

                    d[c]='p'

            else:

                ans += s;d[c]='s'



    else:

        if i =='r':

            ans += p ; d[c]='p'

        elif i == 's': 

            ans += r;d[c]='r'

        elif i == 'p': 

            ans += s;d[c]='s'



    c+=1





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

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

t=list(eval(input()))

 

res=0

for i in range(n):

  if i>k-1 and t[i-k]==t[i]:

    t[i]="n"

  if t[i]=="r":

    res+=p

  elif t[i]=="s":

    res+=r

  elif t[i]=="p":

    res+=s

  

print(res)
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(eval(input()))
# d={'r':0,'s':0,'p':0}
d = {}
ans = 0
c = 0
for i in t:
    if c >= k:
        x = d[c - k]
        y = c + k
        if i == "r":
            if x == "p":
                if y < n and t[y] == "s":
                    d[c] = "s"
                else:
                    d[c] = "r"
            else:
                ans += p
                d[c] = "p"
        elif i == "s":
            if x == "r":
                if y < n and t[y] == "p":
                    d[c] = "p"
                else:
                    d[c] = "s"
            else:
                ans += r
                d[c] = "r"
        elif i == "p":
            if x == "s":
                if y < n and t[y] == "r":
                    d[c] = "r"
                else:
                    d[c] = "p"
            else:
                ans += s
                d[c] = "s"
    else:
        if i == "r":
            ans += p
            d[c] = "p"
        elif i == "s":
            ans += r
            d[c] = "r"
        elif i == "p":
            ans += s
            d[c] = "s"
    c += 1
print(ans)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(eval(input()))
res = 0
for i in range(n):
    if i > k - 1 and t[i - k] == t[i]:
        t[i] = "n"
    if t[i] == "r":
        res += p
    elif t[i] == "s":
        res += r
    elif t[i] == "p":
        res += s
print(res)

-# d={'r':0,'s':0,'p':0} -d = {} -ans = 0 -c = 0 -for i in t: -    if c >= k: -        x = d[c - k] -        y = c + k -        if i == "r": -            if x == "p": -                if y < n and t[y] == "s": -                    d[c] = "s" -                else: -                    d[c] = "r" -            else: -                ans += p -                d[c] = "p" -        elif i == "s": -            if x == "r": -                if y < n and t[y] == "p": -                    d[c] = "p" -                else: -                    d[c] = "s" -            else: -                ans += r -                d[c] = "r" -        elif i == "p": -            if x == "s": -                if y < n and t[y] == "r": -                    d[c] = "r" -                else: -                    d[c] = "p" -            else: -                ans += s -                d[c] = "s" -    else: -        if i == "r": -            ans += p -            d[c] = "p" -        elif i == "s": -            ans += r -            d[c] = "r" -        elif i == "p": -            ans += s -            d[c] = "s" -    c += 1 -print(ans) +res = 0 +for i in range(n): +    if i > k - 1 and t[i - k] == t[i]: +        t[i] = "n" +    if t[i] == "r": +        res += p +    elif t[i] == "s": +        res += r +    elif t[i] == "p": +        res += s +print(res)