#include<bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
   cin >> a >> b;

   vector<int> arr(b);
    for (int i = 0; i < b; i++) {
       cin >> arr[i];
    }

   unordered_set<int> counted;
   vector<int> v;

    for (int i = 0; i < b; i++) {
        if (counted.find(arr[i]) == counted.end()) {
            int cnt =count(arr.begin() + i, arr.end(), arr[i]);
            if (cnt >= a) {
                counted.insert(arr[i]);
                v.push_back(arr[i]);
            }
        }
    }

   cout << v.size() <<endl;
    for (const int& num : v) {
       cout << num << ' ';
    }

    return 0;
}
