#include <bits/stdc++.h>
using namespace std;
bool present(deque<int>& q, int a) {
  auto it = find(q.begin(), q.end(), a);
  return it != q.end();
}
int main(int argc, char** argv) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  deque<int> q;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    bool p = !present(q, a);
    if (q.size() < k && p) {
      q.push_front(a);
    } else if (q.size() == k && p) {
      q.pop_back();
      q.push_front(a);
    }
  }
  cout << q.size() << "\n";
  for (auto& x : q) cout << x << " ";
  return 0;
}
