#include <bits/stdc++.h>
using namespace std;

unordered_map<int, int> mp;

int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        mp[x]++;
    }
    vector<int> vk;
    for(auto x : mp){
        if(x.second >= k)
            vk.push_back(x.first);
    }
    cout << vk.size() << "\n";
    for(auto x : vk){
        cout << x << " ";
    }
    cout << "\n";
    return 0;
}