#include <bits/stdc++.h>
using namespace std;
long long b[300500];
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n, m, a[300500], ans = 0, c[300500];
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        cin >> a[i];
        b[a[i]]++;
    }
    for(int i = 1; i <= m; i++){
        if(b[i] >= n){
            ans++;
            c[i] = i;
        }
    }
    cout << ans << "\n";
    for(int i = 1; i <= m; i++){
        if(c[i] > 0){
            cout << c[i] << " ";
        }
    }
}
