#include <bits/stdc++.h>
#define ll long long
// #define int ll
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define in insert
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define deb(x) cout << #x << " = " << x << '\n';
#define file(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
using namespace std;

// const int dx[] = {0, 1, 0, -1};
// const int dy[] = {1, 0, -1, 0};

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int a[300007];
map <int, int> mp;

void solve() {
 vector <int> ans;
  int n, k;
  cin >> k >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (mp[a[i]] >= k) {
      mp[a[i]] = 0;
      ans.pb(a[i]);
    }
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i] << ' ';
  }
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int TT = 1;
	// cin >> TT;
	while(TT--) {
		solve();
	}
	return 0;
}