#include <bits/stdc++.h>
using namespace std;
int main() {
  deque<long long> dq1;
  deque<long long> dq2;
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dq1.push_back(a[i]);
  }
  deque<long long>::iterator it, it2;
  long long dq2_sz;
  for (int i = 0; i < n; i++) {
    if (dq2.empty()) {
      dq2.push_back(a[i]);
    }
    int ck = 1;
    for (int p = 1; p <= k; p++) {
      for (int j = 0; j < dq2.size(); j++) {
        if (dq1.at(i) == dq2.at(j)) {
          ck = 0;
          break;
        }
      }
      if (ck == 0) {
      } else {
        dq2.push_front(dq1.at(i));
        if (dq2.size() > k) dq2.pop_back();
      }
    }
  }
  cout << dq2.size() << endl;
  for (it = dq2.begin(); it != dq2.end(); it++) {
    cout << *it << " ";
  }
  cout << endl;
}
