#include <bits/stdc++.h>
using namespace std;
string debug_string(const string& s) { return '"' + s + '"'; }
string debug_string(bool b) { return (b ? "true" : "false"); }
string debug_string(const char* s) { return debug_string((string)s); }
template <class T, class U>
string debug_string(const pair<T, U>& p);
template <class U>
struct can_be_string {
  template <typename...>
  static int f(...) {
    return 0;
  }
  template <typename T>
  static char f(decltype(to_string(T()), char())) {
    return 'a';
  }
  static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template <class T>
typename enable_if<can_be_string<T>::value, string>::type debug_string(
    const T& a) {
  string s = to_string(a);
  return s;
}
template <class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(
    const T& a) {
  bool first = true;
  string s = "{";
  for (const auto& x : a) {
    if (!first) {
      s += ", ";
    }
    first = false;
    s += debug_string(x);
  }
  s += "}";
  return s;
}
template <class T, class U>
string debug_string(const pair<T, U>& p) {
  string s = "(";
  s += debug_string(p.first);
  s += ", ";
  s += debug_string(p.second);
  s += ")";
  return s;
}
void debug_out() { cerr << '\n'; }
template <class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
  cerr << ' ' << debug_string(head);
  debug_out(tail...);
}
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> b;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (find(b.begin(), b.end(), a[i]) != b.end()) {
      continue;
    }
    if ((int)b.size() < k) {
      b.insert(b.begin(), a[i]);
    } else {
      b.pop_back();
      b.insert(b.begin(), a[i]);
    };
  }
  cout << b.size() << '\n';
  for (auto x : b) {
    cout << x << ' ';
  }
  cout << '\n';
  return 0;
}
