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

#define ll long long
#define int long long
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = 10 + 5;
const int mod = 1e9 + 7;

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  
  int n, k;
  vector <int> ans;
  cin >> n >> k;
  map <int, int> mp;
  int a[k + 2];
  for (int i = 1; i <= k; i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  for (int i = 1; i <= k; i++){
    if (mp[a[i]] >= n){
      ans.pb(a[i]);
      mp[a[i]] = -1;
    }
  }
  cout << ans.size() << '\n';
  for (auto x : ans) cout << x << ' ';
}
