N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
T=[a for a in T]
answer=0
takahashi=[]
if N%K==0:
    number=(N/K-1)*K
else:
    number=(N//K)*K
for a in range(K):
    if T[a]=='r':
        answer+=P
        takahashi.append('p')
    elif T[a]=='s':
        answer+=R
        takahashi.append('r')
    else:
        answer+=S
        takahashi.append('s')
for a in range(K,int(number)):
    if T[a]=='r':
        if takahashi[a-K]=='p':
            if T[a+K]=='s':
                takahashi.append('s')
            else:
                takahashi.append('r')
        else:
            answer+=P
            takahashi.append('p')
    elif T[a]=='s':
        if takahashi[a-K]=='r':
            if T[a+K]=='p':
                takahashi.append('p')
            else:
                takahashi.append('s')
        else:
            answer+=R
            takahashi.append('r')
    else:
        if takahashi[a-K]=='s':
            if T[a+K]=='r':
                takahashi.append('r')
            else:
                takahashi.append('p')
        else:
            answer+=S
            takahashi.append('s')
for a in range(int(number),N):
    if T[a]=='r':
        if takahashi[a-K]=='p':
            pass
        else:
            answer+=P
    elif T[a]=='s':
        if takahashi[a-K]=='r':
           pass
        else:
            answer+=R
    else:
        if takahashi[a-K]=='s':
            pass
        else:
            answer+=S
print(answer)


### FIXED CODE ###

N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
T=[a for a in T]
answer=0
takahashi=[]
if N%K==0:
    number=(N/K-1)*K
else:
    number=(N//K)*K
for a in range(K):
    if T[a]=='r':
        answer+=P
        takahashi.append('p')
    elif T[a]=='s':
        answer+=R
        takahashi.append('r')
    else:
        answer+=S
        takahashi.append('s')
for a in range(K,int(number)):
    if T[a]=='r':
        if takahashi[a-K]=='p':
            if a+K<N:
                if T[a + K] == 's':
                    takahashi.append('s')
                else:
                    takahashi.append('r')
            else:
                pass
        else:
            answer+=P
            takahashi.append('p')
    elif T[a]=='s':
        if takahashi[a-K]=='r':
            if a+K<N:
                if T[a + K] == 'p':
                    takahashi.append('p')
                else:
                    takahashi.append('s')
            else:
                pass
        else:
            answer+=R
            takahashi.append('r')
    else:
        if takahashi[a-K]=='s':
            if a+K<N:
                if T[a + K] == 'r':
                    takahashi.append('r')
                else:
                    takahashi.append('p')
            else:
                pass
        else:
            answer+=S
            takahashi.append('s')
for a in range(int(number),N):
    if T[a]=='r':
        if takahashi[a-K]=='p':
            pass
        else:
            answer+=P
    elif T[a]=='s':
        if takahashi[a-K]=='r':
           pass
        else:
            answer+=R
    else:
        if takahashi[a-K]=='s':
            pass
        else:
            answer+=S
print(answer)