#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
  
const ll N = 1e9 + 5;
const ll mod = 1e9 + 7;
const ll inf = 3e5 + 2;

int main() {
    int n;
    cin >> n;
    int m;
    cin >> m;

    map <int, int> counts;
    vector<int> elements;

    for (int i = 0; i < m; ++i) {
        int num;
        cin >> num;
        counts[num]++;
        // cout << num << " -> " << counts[num] << "\n";
        elements.pb(num);
    }

    vector<int> res;

    for (int num : elements) {
        if (counts[num] >= n) {
            res.pb(num);
            counts[num] = 0; 
        }
    }

    cout << res.size() << endl;
    for (int num : res) {
        cout << num << ' ';
    }

    return 0;
}