#include <bits/stdc++.h>
using namespace std;
int n, m, k, p, l, a[300001], c[300002], z, d[300002];
unordered_multiset<int>s;
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        cin >> a[i];
        if(s.count(a[i]) == n-1)
        {
            k++;
            c[++z] = a[i];
             s.insert(a[i]);
        }
        else
        {
        s.insert(a[i]);

        }

    }
    cout << z << endl;
    for (int i = 1; i <= z; i++)
        cout << c[i] << " ";
    /*for (int i = 1; i <=m; i++)
      if(ans.count(a[i]) > 0)
    {
      cout << a[i] << " ";
        ans.erase(a[i]);
    }*/
}
/*2 10
1 3 6 5 3 2 4 5 3 2 */
