Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — concatenation of letters, which correspond to the stages.There are $$$n$$$ stages available. The rocket must contain exactly $$$k$$$ of them. Stages in the rocket should be ordered by their weight. So, after the stage with some letter can go only stage with a letter, which is at least two positions after in the alphabet (skipping one letter in between, or even more). For example, after letter 'c' can't go letters 'a', 'b', 'c' and 'd', but can go letters 'e', 'f', ..., 'z'.For the rocket to fly as far as possible, its weight should be minimal. The weight of the rocket is equal to the sum of the weights of its stages. The weight of the stage is the number of its letter in the alphabet. For example, the stage 'a 'weighs one ton,' b 'weighs two tons, and' z' — $$$26$$$ tons.Build the rocket with the minimal weight or determine, that it is impossible to build a rocket at all. Each stage can be used at most once.

The first line of input contains two integers — $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) – the number of available stages and the number of stages to use in the rocket. The second line contains string $$$s$$$, which consists of exactly $$$n$$$ lowercase Latin letters. Each letter defines a new stage, which can be used to build the rocket. Each stage can be used at most once.

Print a single integer — the minimal total weight of the rocket or -1, if it is impossible to build the rocket at all.

NoteIn the first example, the following rockets satisfy the condition: "adx" (weight is $$$1+4+24=29$$$); "ady" (weight is $$$1+4+25=30$$$); "bdx" (weight is $$$2+4+24=30$$$); "bdy" (weight is $$$2+4+25=31$$$).Rocket "adx" has the minimal weight, so the answer is $$$29$$$.In the second example, target rocket is "belo". Its weight is $$$2+5+12+15=34$$$.In the third example, $$$n=k=2$$$, so the rocket must have both stages: 'a' and 'b'. This rocket doesn't satisfy the condition, because these letters are adjacent in the alphabet. Answer is -1.

using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            char[] str = Console.ReadLine().OrderBy(x => x).ToArray();
            if (nm[1]==1)
            {
                Console.WriteLine((1 + str[0] - 'a'));
                return;
            }
            int count = 0;
            int weitgh = 0;
            for (int i = 0; i < nm[0]; i++)
            {
                weitgh = 1 + str[i] - 'a';
                count = 1;
                int pos = i;

                for (int k = i + 1; k < nm[0]; k++)
                {
                    if (count < nm[1] && str[pos] + 1 < str[k])
                    {
                        weitgh += 1 + str[k] - 'a';
                        count++;
                        pos = k;
                    }
                    if (count == nm[1])
                    {
                        Console.WriteLine(weitgh);
                        return;
                    }
                }
            }
            Console.WriteLine(-1);
        }
    }
}

using System;
class Program
    {
        static void Main(string[] args)
        {
            bool[] db;
            int res = 0, k;
            {
                string[] input = Console.In.ReadToEnd().Split(new char[] { '\n', '\r', ' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
                k = int.Parse(input[1]);
                input[0] = input[1] = null;
                db = new bool[27];
                for (int i = 0; i < input[2].Length;)
                    db[input[2][i++]-96] = true;
            }
            for(int i = 1; k>0;)
            {
                if (i >= db.Length) break;
                for(; i<db.Length; ++i)
                {
                    if(db[i])
                    {
                        --k;
                        res += i;
                        i+=2;
                        break;
                    }
                }
            }
            Console.WriteLine(k > 0 ? -1 : res);
        }
    }

using System;
using System.Linq;

namespace CSharp
{
    public class _1011A
    {
        public static void Main()
        {
            string[] tokens = Console.ReadLine().Split();

            int n = int.Parse(tokens[0]);
            int k = int.Parse(tokens[1]);

            bool[] available = Enumerable.Repeat(false, 26).ToArray();
            foreach (char c in Console.ReadLine())
            {
                available[c - 'a'] = true;
            }

            int[] length = new int[26];
            int[] weight = new int[26];

            for (int i = 0; i < 26; i++)
            {
                length[i] = 0;
                weight[i] = 0;

                if (available[i])
                {
                    for (int j = 0; j <= i - 2; j++)
                    {
                        if (length[j] > length[i])
                        {
                            length[i] = length[j];
                            weight[i] = weight[j];
                        }
                        else if (length[j] == length[i] && weight[j] < weight[i])
                        {
                            weight[i] = weight[j];
                        }
                    }

                    length[i]++;
                    weight[i] += i + 1;

                    if (length[i] == k)
                    {
                        Console.WriteLine(weight[i]);
                        return;
                    }
                }
            }

            Console.WriteLine(-1);
        }
    }
}

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        private static int n, k;
        private static bool[] c = new bool[26];
        private static string t;

        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            n = int.Parse(s[0]); k = int.Parse(s[1]);
            t = Console.ReadLine();
            for (int i = 0; i < t.Length; ++i)
            {
                c[t[i] - 'a'] = true;
            }
            int ans = 0;
            int last = -2;
            for (int i = 0; i < 26 && k > 0; ++i)
            {
                if (c[i] == true && i - last >= 2)
                {
                    ans += i + 1;
                    last = i;
                    k--;
                }
            }
            if (k > 0)
                ans = -1;
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

using System;
using System.Linq;
using System.Text;
class Program
{
  public static void Main(string[] args)
  {
    int[] inputs = Console.ReadLine().Split().Select(w => Convert.ToInt32(w)).ToArray();
    string stages =  new string (Console.ReadLine().OrderBy(c => c).ToArray());
    char current = stages[0];
    StringBuilder sb = new StringBuilder();
    sb.Append(current);
    //Console.WriteLine(stages);
    for(int i = 1;i<stages.Length;++i)
      if(stages[i] - current >= 2) {sb.Append(stages[i]); current = stages[i];}
    if(sb.ToString().Length < inputs[1]) Console.WriteLine(-1); else
      Console.WriteLine(sb.ToString().Substring(0,inputs[1]).Select(w => Convert.ToInt32(w) - 'a' + 1).Aggregate((a,b) => a+b));

  }
}

using System;

namespace testProject
{
    class Program
    {
        static void Main()
        {
            var data = Console.ReadLine().Split(' ');
            var n = int.Parse(data[0]);
            var k = int.Parse(data[1]);
            var steps = Console.ReadLine().ToCharArray();
            Array.Sort(steps);
            var result = 0;
            var j = 0;
            var temp = steps[0];

            for (var i = 0; i < n && j < k; i++)
            {
                if (i == 0)
                {
                    result += steps[0] - 96;
                    j++;
                }
                else if (steps[i] > temp + 1)
                {
                    result += steps[i] - 96;
                    temp = steps[i];
                    j++;
                }
            }
            if (j < k)
                Console.WriteLine(-1);
            else
                Console.WriteLine(result);
        }
    }
}

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

namespace AlgoTasks
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split().Select(t => int.Parse(t)).ToArray();
            int n = nk[0];
            int k = nk[1];
            List<char> s = new List<char>(Console.ReadLine());
            s.Sort();
            char last = s[0];
            int j = 1;
            int a = 'a';
            int tons = s[0] - a + 1;
            for (int i = 1; i < n && j < k; i++)
            {
                if (s[i] - last < 2)
                    continue;

                last = s[i];
                tons += s[i] - a + 1;
                j++;
            }

            if (j == k)
                Console.WriteLine(tons);
            else
                Console.WriteLine(-1);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Media;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string alph = "abcdefghijklmnopqrstuvwxyz";
            string[] y = Console.ReadLine().Split(' ');
            int a = int.Parse(y[1]);
            string b = Console.ReadLine();
            int[] alf = new int[b.Length];
            for (int i = 0; i < b.Length; i++)
            {
                for (int j = 0; j < alph.Length; j++)
                {
                    if (b[i] == alph[j])
                    {
                        alf[i] = j + 1;
                        break;
                    }
                }
            }
            int ii = 1;
            int h = 0;
            int sum = 0;
            int max = -1;
            bool g = false;
            Array.Sort(alf);
            for (int i = 0; i < b.Length; i++)
            {

                if ((alf[i] - max) > 1)
                {
                    //ii = i - 1;
                    max = alf[i];
                    //if (g == false)
                    //{
                    //    sum = 0;
                    //    g = true;
                    //}

                    sum += alf[i];
                    h++;
                    //Console.Write(alf[i]);
                    //Console.Write(" ");
                }
                if (h == a)
                    break;
            }

            //sum++;
            if (h < a)
                Console.Write(-1);
            else
                Console.Write(sum);
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;

class Solver
{
    Scanner sc = new Scanner();
    //

    public void Solve()
    {
        int n, k;
        sc.Make(out n, out k);
        var s = ReadLine().ToCharArray().Select(v=>(int)v-'a'+1).ToArray();
        Array.Sort(s);
        var last = -2;var ct = 0;var res = 0;
        for(var i = 0; i < n; i++)
        {
            if (last + 1 >= s[i])
                continue;
            res += s[i];
            last = s[i];
            ct++;
            if (ct == k) Fail(res);
        }
        WriteLine(-1);
    }
}

#region Template
public class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T num, T val) where T : IComparable<T>
    { if (num.CompareTo(val) == 1) { num = val; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T num, T val) where T : IComparable<T>
    { if (num.CompareTo(val) == -1) { num = val; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T v1, ref T v2)
    { var t = v2; v2 = v1; v1 = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f();
        return rt;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f(i);
        return rt;
    }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    public Pair<T1, T2> PairMake<T1, T2>() => new Pair<T1, T2>(Next<T1>(), Next<T2>());
    public Pair<T1, T2, T3> PairMake<T1, T2, T3>() => new Pair<T1, T2, T3>(Next<T1>(), Next<T2>(), Next<T3>());
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
}

public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString()
        => $"{v1.ToString()} {v2.ToString()}";
    public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString()
        => $"{base.ToString()} {v3.ToString()}";
    public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }
}
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            //a = 97, z = 122
            var nums = Console.ReadLine().Split();
            int n = int.Parse(nums[0]);
            int k = int.Parse(nums[1]);

            char[] chs = Console.ReadLine().ToCharArray();

            chs = chs.OrderBy(ch => ch).ToArray();

            int sum = chs[0] - 96;
            int q = 1;

            for (int i = 0; i < n - 1 && q < k; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    char c1 = chs[i];
                    char c2 = chs[j];

                    if (chs[j] - chs[i] >= 2)
                    {
                        sum += chs[j] - 96;
                        q++;
                        i = j - 1;
                        break;
                    }
                }
            }

            if (q == k)
                Console.WriteLine(sum);
            else
                Console.WriteLine(-1);
        }

    }
}

using System;
using System.IO;
using System.Linq;
using System.Text;

namespace Stages
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int[] n = reader.ReadLine().Split(' ').Select(int.Parse).ToArray();
            char[] s = reader.ReadLine().Distinct().OrderBy(t => t).ToArray();

            int sum = 0;
            int cnt = 0;
            var prev = (char) 1;
            foreach (char c in s)
            {
                if (c - prev > 1)
                {
                    sum += c - 'a' + 1;
                    prev = c;
                    cnt++;
                    if (cnt == n[1])
                        break;
                }
            }
            if (cnt != n[1])
                return -1;

            return sum;
        }
    }
}

using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		string[]s=Console.ReadLine().Split();
		int n=int.Parse(s[0]);
		int k=int.Parse(s[1]);
		string now=Console.ReadLine();
		char[]cc=now.ToCharArray();
		Array.Sort(cc);
		now=new string(cc);
		bool no=false;
		int done=(int)(now[0]-'a')+1;
		int count=1;
		for(int i=0;i<now.Length;)
		{
			if(count==k)break;
			int ind=-1;
			for(int j=i+1;j<now.Length;j++)
			{
				if((int)(now[j]-'a')-(int)(now[i]-'a')>=2)
				{
					ind=j;break;
				}
			}
			if(ind==-1)
			{
				no=true;
				break;
			}
			else
			{
				count++;
				done+=(int)(now[ind]-'a')+1;
				i=ind;
			}
		}
		if(no || count!=k)Console.WriteLine(-1);
		else Console.WriteLine(done);
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

   public class test
   {
   public static void Main()
        {
            var A = Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), int.Parse);

            int N = A[0];
            int K = A[1];

            var s = Console.ReadLine();

            var res = s.Distinct().OrderBy(x => x).ToList();
            int i = 0;
            int w = 0;
            char prev = res[0];
            w += (res[0] - 'a') + 1;
            i = 1;
            int used = 1;

            while (used < K)
            {
                if (i < res.Count)
                {
                    if (res[i] - prev > 1)
                    {
                        w += (res[i] - 'a') + 1;
                        prev = res[i];
                        used++;
                    }
                }
                else
                {
                    Console.WriteLine(-1);
                    return;
                }

                i++;
            }

            Console.WriteLine(w);

        }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //int intTemp = Convert.ToInt32(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            string str = Console.ReadLine();
            int noStage = Convert.ToInt32(input[0]);
            int useStage = Convert.ToInt32(input[1]);
            List<char> strarr = str.ToList();
           strarr = strarr.Distinct().ToList();
            if (useStage > strarr.Count)
            {
                Console.WriteLine(-1);
                return;
            }
            strarr.Sort();
            for (int i = 0; i < strarr.Count - 1; i++)
            {
                if ((int)strarr[i + 1] - (int)strarr[i] == 0 || (int)strarr[i + 1] - (int)strarr[i] == 1)
                {
                    strarr.RemoveAt(i + 1);
                }
            }
            if (useStage > strarr.Count)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(strarr.Take(useStage).Sum(c => (int)c - 96));
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp13
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k;
            string input = Console.ReadLine();
            n = int.Parse(input.Split(' ')[0]);
            k = int.Parse(input.Split(' ')[1]);
            input = Console.ReadLine();
            int[] arr = new int[26];
            for (int i = 0; i < n; i++)
            {
                arr[input[i] - 'a']++;
            }

            int ot = 0, sum = 0;
            for (int i = 0; i < 26; i++)
            {
                if (ot > 0)
                {
                    ot--;
                    continue;
                }
                if (int.Parse(arr[i].ToString()) != 0)
                {
                    k--;
                    sum += i + 1;
                    ot += 1;
                }
                if (k == 0) break;
            }
            if (k > 0) Console.WriteLine(-1);
            else
            {
                Console.WriteLine(sum);
            }
        }
    }
}

using System;

namespace A
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int[] nk = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
			string s = Console.ReadLine();
			char[] stages = s.ToCharArray();
			Array.Sort(stages);
			int min = (int)(stages[0] - 'a')+1;
			char last = stages[0];
			int number = 1;
			if (nk[1] > 1)
			{
				for (int i = 1; i < nk[0]; i++)
				{
					if ((int)stages[i] > ((int)last) + 1)
					{
						min += (int)(stages[i] - 'a') + 1;
						last = stages[i];
						number++;
						if (number == nk[1])
						{
							Console.WriteLine(min);
							break;
						}
					}
				}
				if (number < nk[1])
					Console.WriteLine(-1);
			}
			else
				Console.WriteLine(min);
		}
	}
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using static CF.ReadNext;

namespace CF
{
    public static class Program
    {
        private static void Main()
        {
            var n = NextInt();
            var k = NextInt();
            var chars = NextWord().ToCharArray();
            chars = chars.OrderBy(x => x).ToArray();

            var result = chars[0].ToString();
            var j = 0;
            for (var i = 1; i < chars.Length; i++)
            {
                if (j == k - 1)
                {
                    var ans = 0;
                    foreach (var c in result)
                    {
                        ans += c - 'a' + 1;
                    }

                    Console.WriteLine(ans);
                    return;
                }

                if (chars[i] - result[j] >= 2)
                {
                    result += chars[i];
                    j++;
                }
            }

            if (j == k - 1)
            {
                var ans = 0;
                foreach (var c in result)
                {
                    ans += c - 'a' + 1;
                }

                Console.WriteLine(ans);
                return;
            }

            Console.WriteLine("-1");

        }
    }

    public static class ReadNext
    {
        public static int NextInt()
        {
            var next = ReadUntilSpace();
            return int.Parse(next);
        }

        public static double NextDouble()
        {
            var next = ReadUntilSpace();
            return double.Parse(next);
        }

        public static string NextWord()
        {
            return ReadUntilSpace();
        }

        private static bool IsWhiteSpace(int n)
        {
            return n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1;
        }

        private static string ReadUntilSpace()
        {
            var result = "";

            var n = Console.Read();
            // read whitespace
            while (IsWhiteSpace(n))
            {
                n = Console.Read();
            }

            // read characters
            while (!IsWhiteSpace(n))
            {
                result += (char)n;
                n = Console.Read();
            }

            return result;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
using System.Collections;

// binary search --> use inclusive bounds and condition <=
namespace CodePractice
{
    public class Program
    {
        public static void Main()
        {
            ConsoleReader r = new ConsoleReader();
            TextWriter w = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));
            Solve(r, w);
            w.Close();
            //Console.ReadKey();
        }

        public static void Solve(ConsoleReader reader, TextWriter writer)
        {
            A(reader, writer);
        }

        public static void C(ConsoleReader reader, TextWriter writer)
        {
            B(reader, writer);
        }

        public static void B(ConsoleReader reader, TextWriter writer)
        {
            A(reader, writer);
        }

        public static void A(ConsoleReader reader, TextWriter writer)
        {
            int n = reader.NextInt(), k = reader.NextInt();
            char[] stages = reader.NextString().ToCharArray();
            Array.Sort(stages);

            int cost = stages[0] - 'a' + 1;
            int stage = 1, lastStage = 0;

            for(int i = 1; i < n; i++)
            {
                if (stage == k)
                    break;
                if (stages[i] - stages[lastStage] > 1)
                {
                    cost += stages[i] - 'a' + 1;
                    lastStage = i;
                    stage++;
                }
            }

            if (stage == k)
                Console.WriteLine(cost);
            else
                Console.WriteLine("-1");
        }
    }

    public class ConsoleReader
    {
        private String[] data;
        private int wordIndex = 0;

        private void ReadLineIfNeeded()
        {
            while (data == null || wordIndex >= data.Length)
            {
                wordIndex = 0;
                data = Console.ReadLine().Trim().Split();
            }
        }

        public long NextLong()
        {
            ReadLineIfNeeded();
            return long.Parse(data[wordIndex++]);
        }

        public int NextInt()
        {
            ReadLineIfNeeded();
            return int.Parse(data[wordIndex++]);
        }

        public void NextArray(long[] a, int n)
        {
            for (int i = 0; i < n; i++)
            {
                a[i] = NextLong();
            }
        }

        public void NextArray(int[] a, int n)
        {
            for (int i = 0; i < n; i++)
            {
                a[i] = NextInt();
            }
        }

        public string NextString()
        {
            ReadLineIfNeeded();
            return data[wordIndex++];
        }

        //ReadLine()

    }

}

// Codeforces.ConsoleTemplate.CSharp
// https://www.nuget.org/packages/Codeforces.ConsoleTemplate.CSharp

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace A
{
    public class Solution
    {
        public void Execute()
        {
            var (n, k) = ReadTwoInt;
            var s = ReadLine;

            var a = s.Select(x => (int)(x - 'a' + 1)).ToArray();
            Array.Sort(a);
            var result = 0;
            var count = 0;
            var last = int.MinValue;
            for (var i = 0; i < a.Length; ++i)
            {
                if (a[i] > last + 1)
                {
                    result += a[i];
                    last = a[i];
                    ++count;
                }
                if (count == k)
                {
                    break;
                }
            }

            if (count == k)
            {
                WriteLine(result);
            }
            else
            {
                WriteLine(-1);
            }
        }

        private StreamReader reader;
        private StreamWriter writer;

        public Solution(StreamReader reader, StreamWriter writer)
        {
            this.reader = reader;
            this.writer = writer;
        }

        private string ReadLine => reader.ReadLine();
        private int ReadInt => ReadLine.ToInt();
        private long ReadLong => ReadLine.ToLong();
        private double ReadDouble => ReadLine.ToDouble();
        private T Read<T>() => (T)Convert.ChangeType(ReadLine, typeof(T));

        private (T, T) ReadTwo<T>(char c = ' ') => Reads<T>(c).ToTwoTuple();
        private (int, int) ReadTwoInt => ReadTwo<int>();
        private (long, long) ReadTwoLong => ReadTwo<long>();
        private (double, double) ReadTwoDouble => ReadTwo<double>();

        private (T, T, T) ReadThree<T>(char c = ' ') => Reads<T>(c).ToThreeTuple();
        private (int, int, int) ReadThreeInt => ReadThree<int>();
        private (long, long, long) ReadThreeLong => ReadThree<long>();
        private (double, double, double) ReadThreeDouble => ReadThree<double>();

        private string[] Split(char c = ' ') => ReadLine.Split(c);
        private T[] Reads<T>(char c = ' ') => Split(c).Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
        private int[] ReadInts => Split().Select(int.Parse).ToArray();
        private long[] ReadLongs => Split().Select(long.Parse).ToArray();
        private double[] ReadDoubles => Split().Select(double.Parse).ToArray();

        private void Write<T>(T s) => writer.Write(s);
        private void WriteLine<T>(T s) => writer.WriteLine(s);

        private static T SetGreater<T>(ref T a, ref T b) where T : IComparable
        {
            SetLess(ref b, ref a);
            return a;
        }

        private static T SetLess<T>(ref T a, ref T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                Swap(ref a, ref b);
            }
            return a;
        }

        private static void Swap<T>(ref T a, ref T b)
        {
            var temp = b;
            b = a;
            a = temp;
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            // Change the stack size to avoid stack overflow.
            // e.g. stackSizeMb = 128.
            var stackSizeMb = 0;

            if (args.Length > 0 && args.First() == "test")
            {
                if (args.Length > 1)
                {
                    Test(args[1], true);
                }
                else
                {
                    for (var i = 0; i < 10 && Test(i.ToString()); ++i);
                }
            }
            else
            {
                var reader = new StreamReader(Console.OpenStandardInput());
                var writer = new StreamWriter(Console.OpenStandardOutput());
                Run(reader, writer, stackSizeMb);
            }
        }

        private static bool Test(string name, bool show = false)
        {
            var test = $"in{name}.txt";
            if (File.Exists(test))
            {
                var reader = new StreamReader(test);
                var output = new MemoryStream();
                var writer = new StreamWriter(output);
                Run(reader, writer);

                var expect = new StreamReader($"out{name}.txt").ReadToEnd()
                    .Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
                var actual = Encoding.UTF8.GetString(output.ToArray());

                if (show)
                {
                    Console.WriteLine(actual);
                }

                if (actual.TrimEnd() == expect.TrimEnd())
                {
                    WriteLine($"Test {name} passed.", ConsoleColor.Green);
                }
                else
                {
                    WriteLine($"Test {name} failed.", ConsoleColor.Red);
                }

                return true;
            }
            return false;
        }

        private static void Run(StreamReader reader, StreamWriter writer, int stackSize = 0)
        {
            var solution = new Solution(reader, writer);
            if (stackSize == 0)
            {
                solution.Execute();
            }
            else
            {
                var thread = new Thread(solution.Execute, stackSize * 1024 * 1024);
                thread.Start();
                thread.Join();
            }
            writer.Flush();
        }

        private static void WriteLine(string s, ConsoleColor color)
        {
            Console.ForegroundColor = color;
            Console.WriteLine(s);
            Console.ResetColor();
        }
    }

    public static class Extensions
    {
        public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
        {
            foreach(T item in enumeration)
            {
                action(item);
            }
        }

        public static (T, T) ToTwoTuple<T>(this IList<T> list) => (list[0], list[1]);
        public static (T, T, T) ToThreeTuple<T>(this IList<T> list) => (list[0], list[1], list[2]);
        public static int ToInt(this string s) => int.Parse(s);
        public static long ToLong(this string s) => long.Parse(s);
        public static double ToDouble(this string s) => double.Parse(s);
        public static string Merge<T>(this IEnumerable<T> enumeration, string split = " ") => string.Join(split, enumeration);
    }
}

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

namespace StupidSolution
{
    static class Program
    {

        static int Main()
        {
            int n, k;
            String line = Console.ReadLine();
            var parts = line.Split(' ');
            n = int.Parse(parts[0]);
            k = int.Parse(parts[1]);
            String letters = Console.ReadLine();
            letters = new string(letters.OrderBy(c => c).ToArray());
            for(int i=0;i<letters.Length;i++)
            {
                int taken = 1;
                int last = (int)letters[i];
                int sum = last - 'a' + 1;
                if (taken == k)
                {
                    Console.WriteLine(sum);
                    return 0;
                }
                for (int j=i;j<letters.Length;j++)
                    if ((int)letters[j] - last > 1)
                    {
                        last = (int)letters[j];
                        sum += last - 'a' + 1;
                        taken++;
                        if (taken == k)
                        {
                            Console.WriteLine(sum);
                            return 0;
                        }
                    }
            }
            Console.WriteLine(-1);
            return 0;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CF1011B
{
    class Program
    {
        static void Main(string[] args)
        {
            int totNums, totNeed;
            string inp;string[] div;

            inp = Console.ReadLine();div = inp.Split(' ');
            totNums = Convert.ToInt32(div[0]);totNeed = Convert.ToInt32(div[1]);
            inp = Console.ReadLine();
            int[] num = new int[totNums];
            for (int i = 0; i < totNums; i++)
                num[i] = inp[i] - 'a' + 1;

            Array.Sort(num);
            int _count = num[0], lastChoose = num[0];totNeed--;
            for(int i = 1; i < totNums; i++) {
                if (totNeed <= 0) break;
                if (num[i] - lastChoose > 1) {
                    _count += num[i];
                    totNeed--;
                    lastChoose = num[i];
                }
            }

            if (totNeed <= 0)
                Console.WriteLine("{0}", _count);
            else Console.WriteLine("-1");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');

            int n = int.Parse(a[0]);

            int k = int.Parse(a[1]);

            string s = Console.ReadLine();

            int ans = 0, count = 0;

            char[] letters = new char[n];

            for (int i = 0; i < n; i++)
                letters[i] = s[i];

            Array.Sort(letters);

            int last = 'a' - 2;

            for(int i = 0; i < n && count < k; i++)
            {
                if(letters[i] - last >= 2)
                {
                    ans += (letters[i] - 'a' + 1);
                    last = letters[i];
                    count++;
                }
            }

            if (count < k)
                ans = -1;
            Console.WriteLine(ans);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace timus1100
{
    class Program
    {

        static void Main(string[] args)
        { int n, k;
            string i="";
            string[] numbers = Console.ReadLine().Split(' ');
            n= int.Parse(numbers[0]);
            k = int.Parse(numbers[1]);

            var source = new[] { Console.ReadLine() };

            var result = source.Select(s => new string(s.OrderBy(ch => ch).ToArray()));

            byte[] bytes = Encoding.ASCII.GetBytes("a");
            foreach (string s in result) i = String.Concat(i, s);
            char last = Convert.ToChar(bytes[0]-2) ;
            int ans = 0;
            int len = 0;
            for (int ik = 0; ik < n; ik++)

                if (i[ik] >= last + 2)
                {
                    last = i[ik];
                    ans += i[ik] - 'a' + 1;
                    len++;
                    if (len == k)
                    {
                        Console.WriteLine(ans);
                        //Console.ReadKey();
                        Environment.Exit(0);

}
                }
                 Console.WriteLine("-1");

         //  Console.ReadKey();

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            const int N = 96;
            var n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = Console.ReadLine();
            var a1 = new int[n[0]];
            for(int i = 0; i < n[0]; i++)
            {
                a1[i] = a[i] - N;
            }

            Array.Sort(a1);
            if(n[1]==1)
            {
                Console.Write(a1[0]);
                return;
            }

            int total = a1[0];
            int k = 1;
            var temp = a1[0];
            for (int i = 1; i < n[0]; i++){

                if(a1[i]- temp > 1)
                {
                    total += a1[i];
                    k++;
                    temp = a1[i];
                    if (k == n[1]) break;
                }
            }
            if (k != n[1])
            {
                Console.Write(-1);
            }
            else
            {
                Console.Write(total);
            }

        }
    }
}

using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            char[] str = Console.ReadLine().OrderBy(x => x).ToArray();
            int count = 0;
            int weitgh = 0;
            for (int i = 0; i < nm[0]; i++)
            {
                weitgh = 1 + str[i] - 'a';
                count = 1;
                int pos = i;

                for (int k = i + 1; k < nm[0]; k++)
                {
                    if (count < nm[1] && str[pos] + 1 < str[k])
                    {
                        weitgh += 1 + str[k] - 'a';
                        count++;
                        pos = k;
                    }
                    if (count == nm[1])
                    {
                        Console.WriteLine(weitgh);
                        return;
                    }
                }
            }
            Console.WriteLine(-1);
        }
    }
}

using System;

namespace testProject
{
    class Program
    {
        static void Main()
        {
            var data = Console.ReadLine().Split(' ');
            var n = int.Parse(data[0]);
            var k = int.Parse(data[1]);
            var steps = Console.ReadLine().ToCharArray();
            Array.Sort(steps);
            var result = 0;
            var j = 0;
            var temp = steps[0];

            for (var i = 0; i < n || j < k; i++)
            {
                if (i == 0)
                {
                    result += steps[0] - 96;
                    j++;
                }
                else if (steps[i] > temp + 1)
                {
                    result += steps[i] - 96;
                    temp = steps[i];
                    j++;
                }
            }
            if (j < k)
                Console.WriteLine(-1);
            else
                Console.WriteLine(result);
        }
    }
}

using System;

namespace testProject
{
    class Program
    {
        static void Main()
        {
            var data = Console.ReadLine().Split(' ');
            var n = int.Parse(data[0]);
            var k = int.Parse(data[1]);
            var steps = Console.ReadLine().ToCharArray();
            Array.Sort(steps);
            var result = 0;
            var j = 0;

            for (var i = 0; i < n && j < k; i++)
            {
                if (i == 0)
                {
                    result += steps[0] - 96;
                    j++;
                }
                else if (steps[i] > steps[i - 1] + 1)
                {
                    result += steps[i] - 96;
                    j++;
                }
                Console.WriteLine(result);
                Console.WriteLine(' ');
            }
            if (j < k)
                Console.WriteLine(-1);
            else
                Console.WriteLine(result);
        }
    }
}

using System;

namespace testProject
{
    class Program
    {
        static void Main()
        {
            var data = Console.ReadLine().Split(' ');
            var n = int.Parse(data[0]);
            var k = int.Parse(data[1]);
            var steps = Console.ReadLine().ToCharArray();
            Array.Sort(steps);
            var result = 0;
            var j = 0;

            for (var i = 0; i < n && j < k; i++)
            {
                if (i == 0)
                {
                    result += steps[0] - 96;
                    j++;
                }
                else if (steps[i] > steps[i - 1] + 1)
                {
                    result += steps[i] - 96;
                    j++;
                }
            }
            if (j < k)
                Console.WriteLine(-1);
            else
                Console.WriteLine(result);
        }
    }
}

using System;

namespace testProject
{
    class Program
    {
        static void Main()
        {
            var data = Console.ReadLine().Split(' ');
            var n = int.Parse(data[0]);
            var k = int.Parse(data[1]);
            var steps = Console.ReadLine().ToCharArray();
            Array.Sort(steps);
            var result = 0;
            var j = 0;
            var temp = steps[0];

            for (var i = 0; i < n && j < k; i++)
            {
                if (i == 0)
                {
                    result += steps[0] - 96;
                    j++;
                }
                else if (steps[i] > temp + 1)
                {
                    result += steps[i] - 96;
                    temp = steps[i];
                    j++;
                }
                Console.WriteLine(result);
                Console.WriteLine(" ");
            }
            if (j < k)
                Console.WriteLine(-1);
            else
                Console.WriteLine(result);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Media;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string alph = "abcdefghijklmnopqrstuvwxyz";
            string[] y = Console.ReadLine().Split(' ');
            int a = int.Parse(y[1]);
            string b = Console.ReadLine();
            int[] alf = new int[b.Length];
            for (int i = 0; i < b.Length; i++)
            {
                for (int j = 0; j < alph.Length; j++)
                {
                    if (b[i] == alph[j])
                    {
                        alf[i] = j + 1;
                        break;
                    }
                }
            }
            int ii = 1;
            int h = 0;
            int sum = -1;
            int max = 0;
            bool g = false;
            Array.Sort(alf);
            for (int i = 0; i < b.Length; i++)
            {

                if ((alf[i] - max) > 1)
                {
                    //ii = i - 1;
                    if (g == false)
                    {
                        sum = 0;
                        g = true;
                    }
                    max = alf[i];
                    sum += alf[i];
                    h++;
                    //Console.Write(alf[i]);
                    //Console.Write(" ");
                }
                if (h == a)
                    break;
            }

            //sum++;
            Console.Write(sum);
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Media;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string alph = "abcdefghijklmnopqrstuvwxyz";
            string[] y = Console.ReadLine().Split(' ');
            int a = int.Parse(y[1]);
            string b = Console.ReadLine();
            int[] alf = new int[b.Length];
            for (int i = 0; i < b.Length; i++)
            {
                for (int j = 0; j < alph.Length; j++)
                {
                    if (b[i] == alph[j])
                    {
                        alf[i] = j+1;
                        break;
                    }
                }
            }
            int ii = 1;
            int h = 0;
            int sum = -1;
            int max = 0;
            Array.Sort(alf);
            for (int i = 0; i < b.Length; i++)
            {

                if ((alf[i] - max) > 1)
                {
                    //ii = i - 1;
                    max = alf[i];
                    sum += max;
                    h++;
                    //Console.Write(alf[i]);
                    //Console.Write(" ");
                }
                if (h == a)
                    break;
            }
            //sum++;
            Console.Write(sum);
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Media;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string alph = "abcdefghijklmnopqrstuvwxyz";
            string[] y = Console.ReadLine().Split(' ');
            int a = int.Parse(y[1]);
            string b = Console.ReadLine();
            int[] alf = new int[b.Length];
            for (int i = 0; i < b.Length; i++)
            {
                for (int j = 0; j < alph.Length; j++)
                {
                    if (b[i] == alph[j])
                    {
                        alf[i] = j + 1;
                        break;
                    }
                }
            }
            int ii = 1;
            int h = 0;
            int sum = 0;
            int max = -1;
            bool g = false;
            Array.Sort(alf);
            for (int i = 0; i < b.Length; i++)
            {

                if ((alf[i] - max) > 1)
                {
                    //ii = i - 1;
                    max = alf[i];
                    //if (g == false)
                    //{
                    //    sum = 0;
                    //    g = true;
                    //}

                    sum += alf[i];
                    h++;
                    //Console.Write(alf[i]);
                    //Console.Write(" ");
                }
                if (h == a)
                    break;
            }

            //sum++;
            Console.Write(sum);
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            //a = 97, z = 122
            var nums = Console.ReadLine().Split();
            int n = int.Parse(nums[0]);
            int k = int.Parse(nums[1]);

            char[] chs = Console.ReadLine().ToCharArray();

            chs = chs.OrderBy(ch => ch).ToArray();

            int sum = chs[0] - 96;
            int q = 1;

            for (int i = 1; i < n - 1 && q < k; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    char c1 = chs[i];
                    char c2 = chs[j];

                    if (chs[j] - chs[i] >= 2)
                    {
                        sum += chs[j] - 96;
                        q++;
                        i = j - 1;
                        break;
                    }
                }
            }

            if (q == k)
                Console.WriteLine(sum);
            else
                Console.WriteLine(-1);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            //a = 97, z = 122
            var nums = Console.ReadLine().Split();
            int n = int.Parse(nums[0]);
            int k = int.Parse(nums[1]);

            char[] chs = Console.ReadLine().ToCharArray();

            chs = chs.OrderBy(ch => ch).ToArray();

            int sum = chs[0] - 96;
            int q = 1;

            for (int i = 1; i < n && q < k; i++)
            {
                if (chs[i] - chs[i - 1] >= 2)
                {
                    sum += chs[i] - 96;
                    q++;
                }
            }

            if (q == k)
                Console.WriteLine(sum);
            else
                Console.WriteLine(-1);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

   public class test
   {
   public static void Main()
        {
            var A = Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), int.Parse);

            int N = A[0];
            int K = A[1];

            var s = Console.ReadLine();

            var res = s.Distinct().OrderBy(x => x).ToList();
            int i = 0;
            int w = 0;
            char prev = res[0];
            w += (res[0] - 'a') + 1;
            i = 1;
            int used = 1;

            while (used < K)
            {
                if (i < res.Count)
                {
                    if (res[i] - prev > 2)
                    {
                        w += (res[i] - 'a') + 1;
                        prev = res[i];
                        used++;
                    }
                }
                else
                {
                    Console.WriteLine(-1);
                    return;
                }

                i++;
            }

            Console.WriteLine(w);

        }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //int intTemp = Convert.ToInt32(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            string str = Console.ReadLine();
            int noStage = Convert.ToInt32(input[0]);
            int useStage = Convert.ToInt32(input[1]);
            List<char> strarr = str.ToList();
           // strarr = strarr.Distinct().ToList();
            if (useStage > strarr.Count)
            {
                Console.WriteLine(-1);
                return;
            }
            strarr.Sort();
            for (int i = 0; i < strarr.Count - 1; i++)
            {
                if ((int)strarr[i + 1] - (int)strarr[i] == 0 || (int)strarr[i + 1] - (int)strarr[i] == 1)
                {
                    strarr.RemoveAt(i + 1);
                }
            }
            if (useStage > strarr.Count)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(strarr.Take(useStage).Sum(c => (int)c - 96));
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //int intTemp = Convert.ToInt32(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            string str = Console.ReadLine();
            int noStage = Convert.ToInt32(input[0]);
            int useStage = Convert.ToInt32(input[1]);
            List<char> strarr = str.ToList();
            if (useStage > strarr.Count)
            {
                Console.WriteLine(-1);
                return;
            }
            strarr.Sort();
            for (int i = 0; i < strarr.Count - 1; i++)
            {
                if ((int)strarr[i + 1] - (int)strarr[i] == 0 || (int)strarr[i + 1] - (int)strarr[i] == 1)
                {
                    strarr.RemoveAt(i + 1);
                }
            }
            if (useStage > strarr.Count)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(strarr.Take(useStage).Sum(c => (int)c - 96));
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using static CF.ReadNext;

namespace CF
{
    public static class Program
    {
        private static void Main()
        {
            var n = NextInt();
            var k = NextInt();
            var chars = NextWord().ToCharArray();
            chars = chars.OrderBy(x => x).ToArray();

            var result = chars[0].ToString();
            var j = 0;
            for (var i = 1; i < chars.Length; i++)
            {
                if (chars[i] - result[j] >= 2)
                {
                    result += chars[i];
                    j++;
                }

                if (j == k - 1)
                {
                    var ans = 0;
                    foreach (var c in result)
                    {
                        ans += c - 'a' + 1;
                    }

                    Console.WriteLine(ans);
                    return;
                }
            }

            if (j == k - 1)
            {
                var ans = 0;
                foreach (var c in result)
                {
                    ans += c - 'a' + 1;
                }

                Console.WriteLine(ans);
                return;
            }

            Console.WriteLine("-1");

        }
    }

    public static class ReadNext
    {
        public static int NextInt()
        {
            var next = ReadUntilSpace();
            return int.Parse(next);
        }

        public static double NextDouble()
        {
            var next = ReadUntilSpace();
            return double.Parse(next);
        }

        public static string NextWord()
        {
            return ReadUntilSpace();
        }

        private static bool IsWhiteSpace(int n)
        {
            return n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1;
        }

        private static string ReadUntilSpace()
        {
            var result = "";

            var n = Console.Read();
            // read whitespace
            while (IsWhiteSpace(n))
            {
                n = Console.Read();
            }

            // read characters
            while (!IsWhiteSpace(n))
            {
                result += (char)n;
                n = Console.Read();
            }

            return result;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using static CF.ReadNext;

namespace CF
{
    public static class Program
    {
        private static void Main()
        {
            var n = NextInt();
            var k = NextInt();
            var chars = NextWord().ToCharArray();
            chars = chars.OrderBy(x => x).ToArray();

            var result = chars[0].ToString();
            var j = 0;
            for (var i = 1; i < chars.Length; i++)
            {
                if (chars[i] - result[j] >= 2)
                {
                    result += chars[i];
                    j++;
                }

                if (j == k - 1)
                {
                    var ans = 0;
                    foreach (var c in result)
                    {
                        ans += c - 'a' + 1;
                    }

                    Console.WriteLine(ans);
                    return;
                }
            }

            Console.WriteLine("-1");

        }
    }

    public static class ReadNext
    {
        public static int NextInt()
        {
            var next = ReadUntilSpace();
            return int.Parse(next);
        }

        public static double NextDouble()
        {
            var next = ReadUntilSpace();
            return double.Parse(next);
        }

        public static string NextWord()
        {
            return ReadUntilSpace();
        }

        private static bool IsWhiteSpace(int n)
        {
            return n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1;
        }

        private static string ReadUntilSpace()
        {
            var result = "";

            var n = Console.Read();
            // read whitespace
            while (IsWhiteSpace(n))
            {
                n = Console.Read();
            }

            // read characters
            while (!IsWhiteSpace(n))
            {
                result += (char)n;
                n = Console.Read();
            }

            return result;
        }
    }
}

// Codeforces.ConsoleTemplate.CSharp
// https://www.nuget.org/packages/Codeforces.ConsoleTemplate.CSharp

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace A
{
    public class Solution
    {
        public void Execute()
        {
            var (n, k) = ReadTwoInt;
            var s = ReadLine;

            var a = s.Select(x => (int)(x - 'a' + 1)).ToArray();
            Array.Sort(a);
            var result = 0;
            var count = 0;
            var last = int.MinValue;
            for (var i = 0; i < a.Length; ++i)
            {
                if (a[i] > last + 2)
                {
                    result += a[i];
                    last = a[i];
                    ++count;
                }
                if (count == k)
                {
                    break;
                }
            }

            if (count == k)
            {
                WriteLine(result);
            }
            else
            {
                WriteLine(-1);
            }
        }

        private StreamReader reader;
        private StreamWriter writer;

        public Solution(StreamReader reader, StreamWriter writer)
        {
            this.reader = reader;
            this.writer = writer;
        }

        private string ReadLine => reader.ReadLine();
        private int ReadInt => ReadLine.ToInt();
        private long ReadLong => ReadLine.ToLong();
        private double ReadDouble => ReadLine.ToDouble();
        private T Read<T>() => (T)Convert.ChangeType(ReadLine, typeof(T));

        private (T, T) ReadTwo<T>(char c = ' ') => Reads<T>(c).ToTwoTuple();
        private (int, int) ReadTwoInt => ReadTwo<int>();
        private (long, long) ReadTwoLong => ReadTwo<long>();
        private (double, double) ReadTwoDouble => ReadTwo<double>();

        private (T, T, T) ReadThree<T>(char c = ' ') => Reads<T>(c).ToThreeTuple();
        private (int, int, int) ReadThreeInt => ReadThree<int>();
        private (long, long, long) ReadThreeLong => ReadThree<long>();
        private (double, double, double) ReadThreeDouble => ReadThree<double>();

        private string[] Split(char c = ' ') => ReadLine.Split(c);
        private T[] Reads<T>(char c = ' ') => Split(c).Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
        private int[] ReadInts => Split().Select(int.Parse).ToArray();
        private long[] ReadLongs => Split().Select(long.Parse).ToArray();
        private double[] ReadDoubles => Split().Select(double.Parse).ToArray();

        private void Write<T>(T s) => writer.Write(s);
        private void WriteLine<T>(T s) => writer.WriteLine(s);

        private static T SetGreater<T>(ref T a, ref T b) where T : IComparable
        {
            SetLess(ref b, ref a);
            return a;
        }

        private static T SetLess<T>(ref T a, ref T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                Swap(ref a, ref b);
            }
            return a;
        }

        private static void Swap<T>(ref T a, ref T b)
        {
            var temp = b;
            b = a;
            a = temp;
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            // Change the stack size to avoid stack overflow.
            // e.g. stackSizeMb = 128.
            var stackSizeMb = 0;

            if (args.Length > 0 && args.First() == "test")
            {
                if (args.Length > 1)
                {
                    Test(args[1], true);
                }
                else
                {
                    for (var i = 0; i < 10 && Test(i.ToString()); ++i);
                }
            }
            else
            {
                var reader = new StreamReader(Console.OpenStandardInput());
                var writer = new StreamWriter(Console.OpenStandardOutput());
                Run(reader, writer, stackSizeMb);
            }
        }

        private static bool Test(string name, bool show = false)
        {
            var test = $"in{name}.txt";
            if (File.Exists(test))
            {
                var reader = new StreamReader(test);
                var output = new MemoryStream();
                var writer = new StreamWriter(output);
                Run(reader, writer);

                var expect = new StreamReader($"out{name}.txt").ReadToEnd()
                    .Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
                var actual = Encoding.UTF8.GetString(output.ToArray());

                if (show)
                {
                    Console.WriteLine(actual);
                }

                if (actual.TrimEnd() == expect.TrimEnd())
                {
                    WriteLine($"Test {name} passed.", ConsoleColor.Green);
                }
                else
                {
                    WriteLine($"Test {name} failed.", ConsoleColor.Red);
                }

                return true;
            }
            return false;
        }

        private static void Run(StreamReader reader, StreamWriter writer, int stackSize = 0)
        {
            var solution = new Solution(reader, writer);
            if (stackSize == 0)
            {
                solution.Execute();
            }
            else
            {
                var thread = new Thread(solution.Execute, stackSize * 1024 * 1024);
                thread.Start();
                thread.Join();
            }
            writer.Flush();
        }

        private static void WriteLine(string s, ConsoleColor color)
        {
            Console.ForegroundColor = color;
            Console.WriteLine(s);
            Console.ResetColor();
        }
    }

    public static class Extensions
    {
        public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
        {
            foreach(T item in enumeration)
            {
                action(item);
            }
        }

        public static (T, T) ToTwoTuple<T>(this IList<T> list) => (list[0], list[1]);
        public static (T, T, T) ToThreeTuple<T>(this IList<T> list) => (list[0], list[1], list[2]);
        public static int ToInt(this string s) => int.Parse(s);
        public static long ToLong(this string s) => long.Parse(s);
        public static double ToDouble(this string s) => double.Parse(s);
        public static string Merge<T>(this IEnumerable<T> enumeration, string split = " ") => string.Join(split, enumeration);
    }
}

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

namespace StupidSolution
{
    static class Program
    {

        static int Main()
        {
            int n, k;
            String line = Console.ReadLine();
            var parts = line.Split(' ');
            n = int.Parse(parts[0]);
            k = int.Parse(parts[1]);
            String letters = Console.ReadLine();
            letters = new string(letters.OrderBy(c => c).ToArray());
            for(int i=0;i<letters.Length;i++)
            {
                int taken = 1;
                int last = (int)letters[i] - 'a';
                int sum = last;
                for (int j=i;j<letters.Length;j++)
                    if ((int)letters[j] - last > 1)
                    {
                        last = (int)letters[j];
                        sum += last - 'a';
                        taken++;
                        if (taken == k)
                        {
                            Console.WriteLine(sum);
                            return 0;
                        }
                    }
            }
            Console.WriteLine(-1);
            return 0;
        }
    }
}

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

namespace StupidSolution
{
    static class Program
    {

        static int Main()
        {
            int n, k;
            String line = Console.ReadLine();
            var parts = line.Split(' ');
            n = int.Parse(parts[0]);
            k = int.Parse(parts[1]);
            String letters = Console.ReadLine();
            letters = new string(letters.OrderBy(c => c).ToArray());
            for(int i=0;i<letters.Length;i++)
            {
                int taken = 1;
                int last = (int)letters[i];
                int sum = last - 'a' + 1;
                for (int j=i;j<letters.Length;j++)
                    if ((int)letters[j] - last > 1)
                    {
                        last = (int)letters[j];
                        sum += last - 'a' + 1;
                        taken++;
                        if (taken == k)
                        {
                            Console.WriteLine(sum);
                            return 0;
                        }
                    }
            }
            Console.WriteLine(-1);
            return 0;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CF1011B
{
    class Program
    {
        static void Main(string[] args)
        {
            int totNums, totNeed;
            string inp;string[] div;

            inp = Console.ReadLine();div = inp.Split(' ');
            totNums = Convert.ToInt32(div[0]);totNeed = Convert.ToInt32(div[1]);
            inp = Console.ReadLine();
            int[] num = new int[totNums];
            for (int i = 0; i < totNums; i++)
                num[i] = inp[i] - 'a' + 1;

            Array.Sort(num);
            int _count = num[0];totNeed--;
            for(int i = 1; i < totNums; i++) {
                if (totNeed <= 0) break;
                if (num[i] - num[i - 1] > 1) {
                    _count += num[i];
                    totNeed--;
                }
            }

            if (totNeed <= 0)
                Console.WriteLine("{0}", _count);
            else Console.WriteLine("-1");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace timus1100
{
    class Program
    {

        static void Main(string[] args)
        { int n, k;
            string i="";
            string[] numbers = Console.ReadLine().Split(' ');
            n= int.Parse(numbers[0]);
            k = int.Parse(numbers[1]);

            var source = new[] { Console.ReadLine() };

            var result = source.Select(s => new string(s.OrderBy(ch => ch).ToArray()));

            byte[] bytes = Encoding.ASCII.GetBytes("a");
            foreach (string s in result) i = String.Concat(i, s);
            char last = Convert.ToChar(bytes[0]) ;
            int ans = 0;
            int len = 0;
            for (int ik = 0; ik < n; ik++)

                if (i[ik] >= last )
                {
                    last = i[ik];
                    ans += i[ik] - 'a' + 1;
                    len++;
                    if (len == k)
                    {
                        Console.WriteLine(ans);
                        //Console.ReadKey();
                        Environment.Exit(0);

}
                }
                 Console.WriteLine("-1");

         //  Console.ReadKey();

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            const int N = 96;
            var n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = Console.ReadLine();
            var a1 = new int[n[0]];
            for(int i = 0; i < n[0]; i++)
            {
                a1[i] = a[i] - N;
            }

            if (a1.Length == 1)
            {
                Console.Write(a1[0]);
                return;
            }

            Array.Sort(a1);

            int total = a1[0];
            int k = 1;
            for (int i= 1; i < n[0]; i++){
                if(a1[i]-a1[i-1] > 1)
                {
                    total += a1[i];
                    k++;
                    if (k == n[1]) break;
                }
            }
            if (k != n[1])
            {
                Console.Write(-1);
            }
            else
            {
                Console.Write(total);
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            const int N = 96;
            var n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = Console.ReadLine();
            var a1 = new int[n[0]];
            for(int i = 0; i < n[0]; i++)
            {
                a1[i] = a[i] - N;
            }

            Array.Sort(a1);
            if (a1.Length == 1 || n[1]==1)
            {
                Console.Write(a1[0]);
                return;
            }

            int total = a1[0];
            int k = 1;
            for (int i= 1; i < n[0]; i++){
                if(a1[i]-a1[i-1] > 1)
                {
                    total += a1[i];
                    k++;
                    if (k == n[1]) break;
                }
            }
            if (k != n[1])
            {
                Console.Write(-1);
            }
            else
            {
                Console.Write(total);
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            const int N = 96;
            var n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = Console.ReadLine();
            var a1 = new int[n[0]];
            for(int i = 0; i < n[0]; i++)
            {
                a1[i] = a[i] - N;
            }

            Array.Sort(a1);
            if(n[1]==1)
            {
                Console.Write(a1[0]);
                return;
            }

            int total = a1[0];
            int k = 1;
            for (int i = 1; i < n[0]; i++){
                if(a1[i]-a1[i-1] > 1)
                {
                    total += a1[i];
                    k++;
                    if (k == n[1]) break;
                }
            }
            if (k != n[1])
            {
                Console.Write(-1);
            }
            else
            {
                Console.Write(total);
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            const int N = 96;
            var n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = Console.ReadLine();
            var a1 = new int[n[0]];
            for(int i = 0; i < n[0]; i++)
            {
                a1[i] = a[i] - N;
            }
            Array.Sort(a1);
            int total = a1[0];
            int k = 1;
            for (int i= 1; i < n[0]; i++){
                if(a1[i]-a1[i-1] > 1)
                {
                    total += a1[i];
                    k++;
                    if (k == n[1]) break;
                }
            }
            if (k != n[1])
            {
                Console.Write(-1);
            }
            else
            {
                Console.Write(total);
            }

        }
    }
}