using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Io.ReadList<int>();
            var N = NK[0];
            var K = NK[1];
            var RSP = Io.ReadList<int>();
            var R = RSP[0];
            var S = RSP[1];
            var P = RSP[2];
            var T = Io.Read();

            var prevs = new string[N];
            var score = 0l;
            for (var i = 0; i < N; i++)
            {
                var x = "";
                var point = 0;
                switch (T[i])
                {
                    case 'r':
                        x = "p";
                        point = P;
                        break;

                    case 's':
                        x = "r";
                        point = R;
                        break;

                    case 'p':
                        x = "s";
                        point = S;
                        break;
                }

                if (i >= K && prevs[i - K] == x)
                {
                    if (i + K < N)
                    {
                        var afterK = T[i + K];

                        switch (x)
                        {
                            case "r":
                                x = afterK == 'p' ? "p" : "s";
                                break;
                            case "s":
                                x = afterK == 'r' ? "r" : "p";
                                break;
                            case "p":
                                x = afterK == 's' ? "s" : "r";
                                break;
                        }
                    }
                }
                else
                {
                    score += point;
                }

                prevs[i] = x;
            }

            Io.Write(score.ToString());
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }

        class Io
        {
            public static string Read()
            {
                return Console.ReadLine();
            }

            public static IEnumerable<string> ReadRepeat(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read());
            }

            public static T Read<T>()
            {
                return (T)Convert.ChangeType(Read(), typeof(T));
            }

            public static IEnumerable<T> ReadRepeat<T>(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read<T>());
            }

            public static string[] ReadList(char devide = ' ')
            {
                return Read().Split(devide);
            }

            public static T[] ReadList<T>(char devide = ' ')
            {
                return ReadList(devide)
                    .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                    .ToArray();
            }

            public static IEnumerable<T[]> ReadListRepeat<T>(int count, char devide = ' ')
            {
                return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
            }

            public static void Write(string value)
            {
                Console.WriteLine(value);
            }
        }
    }
}


Measured memory_bytes: 14432