#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
const int M = 1e6 + 9;
const long long INF = 1e9 + 7;
const int SM = 1e3 + 5;
const double EPS = 3e-16;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> d;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (find(d.begin(), d.end(), x) != d.end()) {
      continue;
    }
    if (int(d.size()) == k) {
      d.pop_back();
    }
    d.insert(d.begin(), x);
  }
  cout << int(d.size()) << "\n";
  for (auto it : d) cout << it << " ";
  return 0;
}
