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

queue <int> q;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[m + 10];
    for (int i = 0; i < m; i ++)
        cin >> a[i];
    sort(a, a + m);
    int cnt = 0, k = -1, l = -1;
    for (int i = 0; i < m; i++){
        if (k != a[i]){
            cnt = 1;
            k = a[i];
        }else
            cnt++;
        if (cnt >= n && l != a[i]){
            q.push(a[i]);
            l = a[i];
        }
    }
    cout << q.size() << endl;
    while (!q.empty()){
        cout << q.front() << " ";
        q.pop();
    }
}
