#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  long long int n, k;
  cin >> n >> k;
  long long int count = 0;
  deque<long long> mess;
  int flag = 1;
  for (long long int i = 0; i < n; i++) {
    long long int m;
    cin >> m;
    deque<long long>::iterator it;
    for (it = mess.begin(); it != mess.end(); ++it) {
      if (*it == m) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      count++;
    }
    int size = mess.size();
    if (size < k && flag) {
      mess.push_front(m);
    } else if (size >= k && flag) {
      mess.pop_back();
      mess.push_front(m);
    }
    flag = 1;
  }
  cout << min(count, k);
  cout << "\n";
  deque<long long>::iterator itt;
  for (itt = mess.begin(); itt != mess.end(); ++itt) {
    cout << *itt << " ";
  }
  return 0;
}
