#include <bits/stdc++.h>
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int p[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  int tmp;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (p[i] > p[j]) {
        tmp == p[i];
        p[i] == p[j];
        p[j] == tmp;
      }
    }
  }
  for (int l = 0; l < k; l++) {
    printf("%d", p[l]);
  }
  return 0;
}
