#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, t, j, f, l;
  vector<int> a;
  cin >> n >> k;
  t = min(n, k);
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    f = 1;
    l = a.size() - t;
    if (l < 0) l = 0;
    for (j = a.size() - 1; j >= l; j--) {
      if (a[j] == x) {
        f = 0;
        break;
      }
    }
    if (f == 1) a.push_back(x);
  }
  int r = a.size();
  cout << min(t, r) << endl;
  l = a.size() - t;
  if (l < 0) l = 0;
  for (i = a.size() - 1; i >= l; i--) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
