#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200 * 1000 + 1];
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> v;
  for (int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    if (v.empty()) {
      v.push_back(x);
      continue;
    }
    reverse(v.begin(), v.end());
    int it = find(v.begin(), v.begin() + k, x) - (v.begin() + k);
    reverse(v.begin(), v.end());
    if (it == 0) v.push_back(x);
  }
  int x = v.size() - 1;
  cout << (x + 1 < k ? x + 1 : k) << "\n";
  while (k > 0 and x >= 0) {
    cout << v[x] << " ";
    x--;
    k--;
  }
  return 0;
}
