#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector <long long> a;
    for(int i = 0; i < m; i++){
        long long k;
        cin >> k;
        a.push_back(k);
    }
    int s = 1, ans = 0;
    string l = "";
    sort(a.begin(), a.end());
    for(int i = 0; i < m - 1; i++){
        if(a[i] == a[i + 1]){
            s++;
        }else{
            if(s >= n){
                ans++;
                l += to_string(a[i]) + " ";
            }
            s = 1;
        }
    }
    if(s >= n){
        ans++;
        l += to_string(a[m - 1]) + " ";
    }
    cout << ans << endl << l;
    return 0;
}