#include <bits/stdc++.h>
using namespace std;
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, x = 1, p = 1, b[300500];
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        cin >> a[i];
    }
    sort(a + 1, a + m + 1);
    for(int i = 2; i <= m; i++){
        if(a[i] == a[i - 1]){
            x++;
            if(x >= n){
                if(p != a[i]){
                    ans++;
                    b[i] = a[i];
                    p = a[i];
                }
            }
        }
        else {
            x = 1;
        }
    }
    sort(b + 1, b + m + 1);
    cout << ans << "\n";
    for(int i = 1; i <= m; i++){
        if(b[i] >= n){
            cout << b[i] << " ";
        }
    }
}
