#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int id[220];
  queue<int> Q;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &id[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (mp[id[i]] == 1)
      continue;
    else {
      if (Q.size() < k) {
        Q.push(id[i]);
        mp[id[i]] = 1;
      } else if (Q.size() == k) {
        mp[Q.front()] = 0;
        Q.pop();
        Q.push(id[i]);
        mp[id[i]] = 1;
      }
    }
  }
  printf("%d\n", Q.size());
  int b[220];
  int l = 0;
  while (!Q.empty()) {
    l++;
    b[l] = Q.front();
    Q.pop();
  }
  for (int i = l; i >= 1; i--) {
    printf("%d ", b[i]);
  }
}
