#include <bits/stdc++.h>
using namespace std;
long long limit = 4294967296;
int MOD = 1000000007;
template <typename T>
void print(const T& x) {
  cerr << x << ' ';
}
template <typename T1, typename... T2>
void print(const T1& first, const T2&... rest) {
  print(first);
  print(rest...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, k;
  cin >> n >> k;
  deque<int> dq;
  deque<int>::iterator it;
  deque<int>::iterator check;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    check = find(dq.begin(), dq.end(), val);
    if (check == dq.end()) {
      if (dq.size() < k) {
        dq.push_front(val);
      } else {
        dq.pop_back();
        dq.push_front(val);
      }
    }
  }
  cout << dq.size() << endl;
  for (it = dq.begin(); it != dq.end(); it++) cout << *it << " ";
  cout << endl;
  return 0;
}
