# include <bits/stdc++.h>

# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
# define deb(x) cerr << #x  << " = " << x << endl; 
# define pll pair <ll, ll>
# define pii pair <int, int>
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const ll maxn = 2e5 + 7;
const ll inf = 2e18 + 0;
const ll mod = 1e9 + 7;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a[maxn];
map<ll,ll> mp;
void ma1n () {
    int n, m;
    cin >> n >> m;
    vector<int> v;
    for(int i = 1; i <= m; i++){
      cin >> a[i];
      mp[a[i]]++;
    }
    for(int i = 1; i <= m; i++){
      if(mp[a[i]] >= n) v.pb(a[i]) , mp[a[i]] = 0;
    }
    cout << v.size() << "\n";
    for(int x : v){
      cout << x <<" ";
    }
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//  freopen("file.in", "r", stdin);
//  freopen("file.out", "w", stdout);
    int ttt = 1;
//  cin >> ttt;
    for (int test = 1; test <= ttt; ++test) {
//      cout << "Case " << test << ":" << '\n';
        ma1n();
    }
    return 0;
}
