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