#include <iostream>
#include <vector>

int main() {
  long n, k, a, i;
  std::vector <int> v;

  std::cin >> n >> k;
  long u[2*n + 1] = {};

  for (i = 0; i < n; i++) {
    std::cin >> a;
    u[n + a]++;
    if (u[n + a] == k) v.push_back(a);
  }

  std::cout << v.size() << std::endl;
  for (auto const& c : v) {
    std::cout << c << " ";
  }
}