#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n;
  cin >> k;
  long long m = 0;
  long long a[k + 1];
  for (long long i = 0; i < k + 1; ++i) {
    a[i] = -1;
  }
  for (long long i = 0; i < n; ++i) {
    long long z;
    cin >> z;
    bool b = false;
    for (long long j = 0; j < k; ++j) {
      if (a[j] == z) b = true;
    }
    if (!b) {
      for (long long l = k; l > 0; l--) {
        a[l] = a[l - 1];
      }
      a[0] = z;
    }
  }
  for (long long i = 0; i < k; ++i) {
    if (a[i] != -1) m++;
  }
  cout << m << '\n';
  ;
  for (long long i = 0; i < m; ++i) {
    cout << a[i] << ' ';
  }
  return 0;
}
