#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int32_t N, K, A_i, count = 0;

    cin >> N >> K;

    vector<int32_t> replace;
    unordered_map<int32_t, int32_t> freq;

    for(int32_t i = 0; i < N; i++){
        cin >> A_i;
        freq[A_i]++;
    }

    for(auto target : freq){
        if(target.second >= K){
            count++;
            replace.push_back(target.first);
        }
    }

    cout << count << "\n";

    for(int32_t i = 0; i < replace.size(); i++)
        cout << replace[i] << " ";
}