#include <bits/stdc++.h>
using namespace std;
int main() {
  deque<long long> dq;
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (dq.size() == 0) {
      dq.push_back(a[i]);
    } else {
      if (find(dq.begin(), dq.end(), a[i]) == dq.end()) {
        dq.push_front(a[i]);
        if (dq.size() == k + 1) {
          dq.pop_back();
        }
      }
    }
  }
  cout << dq.size() << endl;
  while (!dq.empty()) {
    cout << dq.front() << " ";
    dq.pop_front();
  }
}
