#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const long double PI = acosl(-1.0l);
const long long MAXN = numeric_limits<long long>::max();
const long long MINN = (1e9 + 1);
void solve() {
  int n, k, i;
  cin >> n >> k;
  vector<long long> A(n);
  for (i = 0; i < n; i++) cin >> A[i];
  vector<long long> B;
  B.push_back(A[0]);
  for (i = 1; i < n; i++) {
    if (find((B).begin(), (B).end(), A[i]) == B.end()) {
      if (B.size() >= k) B.pop_back();
      B.insert(B.begin(), A[i]);
    }
  }
  cout << B.size() << endl;
  for (auto it : B) cout << it << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  int t = 1;
  while (t) {
    t--;
    solve();
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
