#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

int main()
{
    int n,k;std::cin >> n >> k;
    std::vector <int> v(n);
    std::map<int,int> m;
    for(auto &i:v) std::cin >> i;
    for (auto i:v) m[i] = 0;
    for (auto i:v) ++m[i];
    std::cout << std::count_if(m.begin(),m.end(),[k1 = k](std::pair<int,int>p){return p.second>= k1;}) << std::endl;
    for (auto i:m) if(i.second >= k) std::cout << i.first << " ";
    return 0;
}