#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i;
  cin >> n >> k;
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  vector<char> v;
  v.push_back(s[0]);
  char ch = s[0];
  for (i = 1; i < n; i++) {
    if ((s[i] - ch) >= 2) {
      ch = s[i];
      v.push_back(s[i]);
    }
  }
  if (v.size() < k) {
    cout << "-1" << endl;
  } else {
    int sum = 0;
    for (i = 0; i < k; i++) {
      sum += (v[i] - '0');
    }
    cout << sum - k * 48 << "\n";
  }
  return 0;
}
