#include <iostream>

using namespace std;

int main()
{
    int n,k,a, br = 0; 
    cin >> n >> k;
    int niz[2*n+1];
    for(int i = 0; i<=2*n; i++)
        niz[i] = 0;
    for(int i = 0; i<n; i++){
        cin >> a;
        niz[a]++;
    }
    for(int i = 0; i<=2*n; i++)
        if(niz[i] >= k)
            br++;
    cout << br << endl;
    for(int i = 0; i<2*n; i++)
        if(niz[i] >= k)
            cout << niz[i] << " ";
    cout << niz[2*n] << endl;
    return 0;
}