inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
K = l.shift() * 1
l = inp.shift().split(' ')
R = l.shift() * 1
S = l.shift() * 1
P = l.shift() * 1
T = inp.shift()
a = ''
c = 0
for (i=0;i<N;i++) {
    s = T[i]
    if (i>=K) {
        b = a[i-K]
    } else {
        b = ''
    }
    if (s == 'r') {
        if (b != 'p') {
            c += P
            a += 'p'
        } else {
            a += '?'
        }
    } else if (s == 's') {
        if (b != 'r') {
            c += R
            a += 'r'
        } else {
            a += '?'
        }
    } else if (s == 'p') {
        if (b != 's') {
            c += S
            a += 's'
        } else {
            a += '?'
        }
    }
}
console.log(c)
