#include <bits/stdc++.h>
using namespace std;
bool search(deque<int> g, int key) {
  deque<int>::iterator it;
  for (it = g.begin(); it != g.end(); ++it)
    if (*it == key) return true;
  return false;
}
void showdq(deque<int> g) {
  deque<int>::iterator it;
  for (it = g.begin(); it != g.end(); ++it) cout << *it << " ";
  cout << '\n';
}
int main() {
  int n, k;
  cin >> n >> k;
  deque<int> g;
  for (int i = 0; i < n; i++) {
    int input;
    cin >> input;
    if (i == 0) {
      g.push_front(input);
      continue;
    }
    if (search(g, input)) continue;
    if (g.size() == k) {
      g.pop_back();
      g.push_front(input);
    } else
      g.push_front(input);
  }
  cout << g.size() << endl;
  showdq(g);
  return 0;
}
