#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long int N, K;
    long int A[100000];
    long int B[100000];
    long int brojac[100000];
    long int br = 0;
    long int kol = 0;

    cin >> N;
    cin >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    sort(A, A + N);

    B[br] = A[0];
    brojac[br] = 1;

    for(int i = 1; i < N; i++){
        if(A[i] != A[i-1]){
           br++;
           B[br] = A[i];
           brojac[br] = 1;
        } else {
           brojac[br]++;
        }
    }

    for(int i = 0; i <= br; i++){
        if(brojac[i] >= K){
            kol++;
        }
    }

    cout << kol << endl;

    for(int i = 0; i <= br; i++){
        if(brojac[i] >= K){
            cout << B[i] << " ";
        }
    }

    return 0;
}