#include <bits/stdc++.h>
using namespace std;
void test_case() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (auto& x : a) cin >> x;
  vector<long long> ans;
  long long pushed = 0;
  for (long long i = 0; i < n; ++i) {
    if (find(ans.begin(), ans.end(), a[i]) != ans.end()) continue;
    if (pushed >= k) {
      ans.erase(ans.begin());
      --pushed;
    }
    ans.push_back(a[i]);
    ++pushed;
  }
  long long m = (long long)ans.size();
  cout << m << '\n';
  for (long long i = m - 1; i >= 0; --i) {
    cout << ans[i] << " \n"[i == n - 1];
  }
  cout << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long TC;
  TC = 1;
  while (TC--) test_case();
  return 0;
}
