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

int main()
{
    std::ios_base::sync_with_stdio(false);
    int c = 0;
    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];
    v.clear();
    for(auto i:m)if(i.second >= k){v.push_back(i.first);++c;};
    std::cout << c << std::endl;
    for(auto i:v) std::cout << i << " ";
    return 0;
}