#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (auto &elem : v) cin >> elem;
    map<int, int> mp;
    for (auto elem : v) mp[elem] = 0;
    for (auto elem : v) mp[elem]++;
    set<int> ans;
    for (auto elem : v) if (mp[elem] >= n) ans.insert(elem);
    cout << ans.size() << endl;
    for (auto elem : ans) cout << elem << ' ';

    return 0;
}
/*
2 10
1 3 6 5 3 2 4 5 3 2

*/
