//#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <random>
#include <chrono>
/*
Bismillah hir rahman nir raheem
*/
using namespace std;
#define ll long long
#define ull unsigned long long 
#define pb(e) push_back(e)
#define all(v) v.begin(), v.end()
void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for( int i = 0; i < m; i++ )
    {
        cin >> a[i];
    }
    vector<int> ans;
    sort(all(a));
    for ( int i = 0; i < m; i++ )
    {
        int j = i;
        while(a[j] == a[i] )
        {
            j++;
        }
        if ( j - i  >= n )
        {
            ans.pb(a[i]);
        }
        i = j - 1;
    }
    cout << ans.size() << endl;
    for ( auto no : ans )
    {
        cout << no << " ";
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1; 
    while (t--)
    {
        solve();
        cout << endl;
    }
    return 0;
}