#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  map<int,int> cnt; 
  for(int i = 0; i < m; i++){
      cin >> a[i];
      cnt[a[i]]++;
  }
  vector<int> f;
  for (auto&& [c, num] : cnt) {
      if(num >= n) {
          f.push_back(c);
      }
  }
  cout << f.size() << endl;
  for(int i = 0; i < f.size(); i++) {
      cout << f[i] << " ";
  }
}