#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  deque<int> v;
  v.push_back(a[0]);
  long long j = 1;
  deque<int>::iterator it;
  if (n > 1) {
    while (v.size() < k) {
      it = find(v.begin(), v.end(), a[j]);
      if (it == v.end()) {
        v.push_back(a[j]);
      }
      j++;
      if (j == n) {
        break;
      }
    }
  }
  if (j == n) {
  } else {
    for (long long p = j - 1; p < n; p++) {
      it = find(v.begin(), v.end(), a[p]);
      if (it == v.end()) {
        v.push_back(a[p]);
        v.pop_front();
      }
    }
  }
  cout << v.size() << "\n";
  for (long long m = v.size() - 1; m >= 0; m--) {
    cout << v[m] << " ";
  }
  cout << "\n";
}
