#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    long long int n,m,a,j,k;
    cin >> n >> m ;
    a=1;
    j=0;
    k=0;
    int *A = new int [m];
    int *B = new int [m];
    for (int i=0;i<m;++i){
        cin >> A[i];
    }
    sort(A,A+m);
    for (int i=1;i<m;++i){
        if (A[i]==A[i-1]){
            a++;
            //cout << a << "\n";
        }
        else {
            if (a>=n){
                B[j]=A[i-1];
                j++;
                k++;
            }
            a=1;
        }
    }
    cout << k << "\n";
    for (int i=0;i<j;++i){
        cout << B[i] << " ";
    }
    return 0;
}
