#include <bits/stdc++.h>
using namespace std;
template <class T>
class Queue {
  T *q;
  int head, tail, size;
  int capacity;

 public:
  Queue(int cap) {
    q = new T[100000];
    head = 0;
    tail = 0;
    size = 100000;
    capacity = cap;
  }
  void enqueue(T obj) {
    bool found = search(obj);
    if (!found) {
      if (tail - head == capacity) {
        T dummy = dequeue();
      }
      q[tail++] = obj;
    }
  }
  T dequeue() { return q[head++]; }
  bool search(T obj) {
    for (int i = head; i < tail; i++) {
      if (q[i] == obj) return true;
    }
    return false;
  }
  void print_rev() {
    cout << tail - head << "\n";
    for (int i = tail - 1; i >= head; i--) {
      cout << q[i] << " ";
    }
  }
  ~Queue() { delete[] q; }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k, temp;
  cin >> n >> k;
  Queue<long long> q(k);
  for (int i = 0; i < n; i++) {
    cin >> temp;
    q.enqueue(temp);
  }
  q.print_rev();
}
