#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    map <long long, int> ans;
    int ans1 = 0;
    for (int i = 0; i < m; i++){
        long long x;
        cin >> x;
        if (ans.count(x) == 0) {
            ans[x] = 1;
        } else {
            ans[x]++;
        }
    }
    vector <long long> arr;
    for (auto elem : ans){
        if (elem.second >= n){
            arr.push_back(elem.first);
            ans1++;
        }
    }
    cout << ans1 << endl;
    for (auto i : arr){
        cout << i << " ";
    }
}
