#include <bits/stdc++.h>
using namespace std;
int *a_heap;
int main() {
  int n1, n2;
  int sum;
  cin >> n1 >> n2;
  a_heap = new int[n1];
  sort(a_heap, a_heap + n1);
  for (int i = 0; i < n2; i++) {
    sum += a_heap[i];
  }
  cout << sum;
}
