#include <bits/stdc++.h>
using namespace std;

unordered_map<int,int> mp;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int>vc;
    for (int i = 0; i < m; i++)
    {
      int x;
      cin >> x;
      mp[x]++;
  }
  for (auto now : mp)
  {
    if (now.second >= n)
    {
      vc.push_back(now.first);
    }
  }
  cout << vc.size() << '\n';
  for (auto now : vc)
  {
    cout << now << ' ';
  }
  cout << '\n';
}
