#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k, i, c;
  cin >> n >> k;
  vector<int> id, message;
  vector<int>::iterator it;
  for (i = 0; i < n; i++) {
    cin >> c;
    id.push_back(c);
    if (i == 0)
      message.push_back(c);
    else {
      it = find(message.begin(), message.end(), c);
      if (it - message.end() == 0 && message[it - message.begin() - 1] != c) {
        message.insert(message.begin(), 1, c);
        if (message.size() > k) message.resize(k);
      }
    }
  }
  cout << message.size() << "\n";
  for (i = 0; i < message.size(); i++) cout << message[i] << " ";
  return 0;
}
