#include <bits/stdc++.h>
#include <algorithm> 
 #include <iostream>

using namespace std;

int main() {
  char n,k,p[1010];
  cin >> n >> k;
  for(int i = 0; i < N; ++i) cin >> p[i];
 sort(p, p + N);
 int ans = 0;
 for(int i = 0; i < K; ++i) ans += p[i];
 cout << ans << endl;
}