#include<stdio.h>
#include <stdlib.h>

void quick_sort(int *ary, int begin, int end){
  int i, j, work, pivot;
  pivot = ary[ ( begin + end ) / 2 ];
  i = begin;
  j = end;
  while( 1 ){
    while( ary[i] < pivot ) ++i;
    while( ary[j] > pivot ) --j;
    if( i >= j) break;
    work = ary[i];
    ary[i] = ary[j];
    ary[j] = work;
    i++;
    j--;
  }
  if( begin < i - 1 ) quick_sort(ary, begin, i - 1 );
  if( j + 1 < end ) quick_sort(ary, j + 1, end );
}
int main(){
int n,k,i;
scanf("%d %d",&n,&k);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
quicksort(a,0,k-1);
for(i=0;i<k;i++)
printf("%d",a[i]);
}