#include <bits/stdc++.h>
int n, k, id, list[40010], front, tail;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &id);
    int flag = 0;
    for (int j = front; j < tail; ++j)
      if (id == list[j]) flag = 1;
    if (flag) continue;
    list[tail++] = id;
    if (tail - front > k) ++front;
  }
  printf("%d\n", tail - front);
  for (int i = tail - 1; i >= front; --i) printf("%d ", list[i]);
  return 0;
}
