#include <bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ll long long
#define ld long double
#define bg begin()
#define nd end()
#define sz size()
#define ers erase
#define ff first
#define ss second

ll binpow(ll a, ll x) {
    if (!x)
        return 1 ;
    if (x & 1)
        return a * binpow(a, x - 1) ;
    ll p = binpow(a, x / 2) ;
        return (p * p) ;
}

const int MAXN = (1 << 18) ;
const int INF = INT_MAX ;

int main() {
//freopen("input.in", "r", stdin) ;
//freopen("output.out", "w", stdout) ;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m ;
    cin >> n >> m ;
    vector<int> a(m) ;
    map<int, int> mp ;
    vector<int> b ;
    for (int& i : a) {
        cin >> i, ++mp[i] ;
        if (mp[i] == 1)
            b.push_back(i) ;
    }
    vector<int> ans ;
    for (int i : b) {
        if (mp[i] >= n)
            ans.push_back(i) ;
    }
    cout << ans.sz << '\n' ;
    for (int i : ans)
        cout << i << ' ' ;
}