#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#include <fstream>

using namespace std;

const long long MAX = 100000000;

struct broj{
	short int num;
	long broj1;
	short int redni;
} polje[MAX];

bool cmp(struct broj a, struct broj b){
	if(a.num > b.num) return true;
	else if(a.num == b.num) return(a.redni < b.redni);
	else return false;	
}


int main(){
	int n, tmp;
	
	long c;
	scanf("%d %ul", &n, &c);
	
	for(long i = 0; i < c; i++){
		polje[i].num = 0;
		polje[i].broj1 = i+1;
		polje[i].redni = -1;	
	}
	
	for(int i = 0; i < n; i++){
		cin>>tmp;
		for(int j = 0; j < c; j++){
			if(polje[j].broj1 == tmp) {
				polje[j].num++;
				if(polje[j].redni == -1) polje[j].redni = i;
			} 	
		}
	}
	sort(polje, polje+c, cmp);
	
	for(int i = 0; i < c; i++){
		for(int j = 0; j < polje[i].num; j++)
			cout<<polje[i].broj1<<" ";	
	}
	cout<<endl;	
		
	//system("pause");
    return 0;
}
