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

void Merge(int l,int s,int d,long long a[]){
	int i,j,k,n1=s-l+1,n2=d-s;
	long L[n1],D[n2];
	for(i=0;i<n1;i++)L[i]=a[l+i];
	for(j=0;j<n1;j++)D[j]=a[s+j+1];
	i=j=0;k=l;
	while(i<n1 && i<n2)if(L[i]>D[j])a[k++]=L[i++];
	else a[k++]=D[j++];
	while(i<n1)a[k++]=L[i++];
	while(j<n2)a[k++]=D[j++];
	}

void MergeSort(long long l,long long d,long long a[]){
	int s=(l+d)/2;
	if(l<d){
		MergeSort(l,s,a);
		MergeSort(s+1,d,a);
		Merge(l,s,d,a);
	}
}

void F(long K,unsigned long long N,long long a[],long brpolja,long long b[]){
	int br=0;
	for(int i=0;i<N;i++){
	if(a[i]=a[i+1])br++;
	if(br>=K)b[brpolja++];
	if(a[i]!=a[i+1])br=0;
	}
	

}

main(){
	unsigned long long N;
	long long a[1000000000], b[10000000];
	long K, brpolja;
	
	scanf("%llu", &N);
	
	do{
		scanf("%ld",&K);
	}while(K>1000 || K<=0);
	
	for(int i=0;i<N;i++)scanf("%lld", &a[i]);
	
	MergeSort(0,N-1,a);
	F(K,N,a,brpolja,b);
	printf("%ld",brpolja);
	for(int i=0;i<brpolja;i++)printf("%lld ",b[i]);
	

	
}