Imports System

Public Class Program


    Public Shared Sub Main(args As String())

        Dim input1() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)
        Dim N As Integer = input1(0)
        Dim K As Integer = input1(1)


        Dim input2() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)
        Dim R As Integer = input2(0)
        Dim S As Integer = input2(1)
        Dim P As Integer = input2(2)

        Dim hands(K - 1) As String

        For i As Integer = 0 To N - 1
            hands(i Mod K) &= System.Text.Encoding.ASCII.GetChars(New Byte() {Console.Read})
        Next

        Dim score As ULong = 0


        For h As Integer = 0 To hands.Length - 1

            Dim prevhand As String = ""

            For i As Integer = 0 To hands(h).Length - 1



                If Not (hands(h)(i) = prevhand) Then

                    Select Case hands(h)(i)
                        Case "r"
                            score += P
                        Case "s"
                            score += R
                        Case "p"
                            score += S
                    End Select
                    prevhand = hands(h)(i)

                Else
                    prevhand = ""
                End If



            Next


        Next


        Console.WriteLine(score)

    End Sub



End Class
