#include <iostream>
#include <set>
using namespace std;
int n, m, k, p, l, a[300002];
multiset<int>s;
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 (int i = 1; i <= m; i++)
  {
      if(s.count(a[i]) >= n)
      ans.insert(a[i]);
  }
  cout << ans.size() << endl;
  for (auto x:ans){
  cout << x << " ";
  }
}