#include <iostream>
using namespace std;

int a[1000000];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int k;
        cin >> k;
        a[k]++;
    }
    int ans = 0;
    for (int i = 0; i < 1000000; i++){
        if (a[i] >= n) ans++;
    }
    cout << ans << endl;
    for (int i = 0; i < 1000000; i++){
        if (a[i] >= n) cout << i << " ";
    }
}
