#include <bits/stdc++.h>
using namespace std;
int n, m, k, p, l, a[300001], c[300002];
unordered_multiset<int>s;
unordered_set<int>ans;
int main()
{
    ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++)
  {
  cin >> a[i];
  s.insert(a[i]);
  }
  for (auto i:s)
  {
      if(s.count(i) >= n)
      ans.insert(i);
  }
  cout << ans.size() << endl;
  for (int i = 1; i <=m; i++)
    if(ans.count(a[i]) > 0)
  {
    cout << a[i] << " ";
      ans.erase(a[i]);
  }
  }

