#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> vc(m);
    int cnt = 0, ans = 0;
    vector<int> s;
    map<int, int> mp;
    for(int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    for(auto i : mp)
    {
        if(i.second >= n) ans++;
    }
    cout << ans << endl;
    for(auto i : mp)
    {
        if(i.second >= n) cout << i.first << " ";
    }
}
