#include<iostream>
#include <set>
using namespace std;
multiset <int> st, x;
int n, m, k = 0, s[300005], a[300005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> a[i];
        st.insert(a[i]);
    }
    for(int i = 1; i <= m; i++)
    {
        if(st.count(a[i]) >= n && x.find(a[i]) == x.end())
        {
            x.insert(a[i]);
            k++;
            s[k] = a[i];
        }
    }
    cout << k << "\n";
    for(int i = 1; i <= k; i++)
        cout << s[i] << " ";
    return 0;
}