#ifdef LOCAL
    #define _GLIBCXX_DEBUG
#endif // LOCAL

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <queue>
#include <iomanip>
#include <iterator>
#include <fstream>
#include <cstdlib>
#include <random>
#include <climits>
#include <chrono>

using namespace std;

#define int long long
#define f first
#define s second
#define fi first
#define se second
#define p_b push_back
#define e_b emplace_back
#define pw(x) (1LL<<((int)x))
#define sz(x) (ll)x.size()
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

using ll = long long;
using ul = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;

const ll N = 2e5 + 5, mod = 1e9+7;

template<class T> inline T sqr(T x) {return x * x;}
template<class T> inline void amin(T &a, T b) {a = a < b ? a : b;}
template<class T> inline void amax(T &a, T b) {a = a > b ? a : b;}
template<class T> inline void smod(T &a, T b) {a = a + b >= mod ? a + b - mod : a + b;}
template<class T> inline void dmod(T &a, T b) {a = a - b >= 0 ? a - b : a - b + mod;}

mt19937 rnd(time(0));

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i =0 ; i < m; i ++)
        cin >> a[i];

    vector<int> ans;
    unordered_map<int, int> cnt;
    for (int i = 0; i < m; i ++)
        cnt[a[i]] ++;
    for (auto i : cnt) {
        if (i.second >= n)
            ans.push_back(i.first);
    }

    cout << sz(ans) << '\n';
    for(int i : ans)
        cout << i << ' ' ;
}

main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    #endif // LOCAL
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    #ifdef LOCAL
        cout << "\n\n===\nTime : " << (long double)clock() / CLOCKS_PER_SEC << '\n';
    #endif // LOCAL
}
