#include <bits/stdc++.h>
int screen[200001];
int main(void) {
  int size, temp, k, p, check;
  scanf("%d %d", &size, &k);
  p = 0;
  for (int i = 0; i < size; i++) {
    scanf("%d", &temp);
    check = 0;
    for (int i = p - 1; i >= p - k && i >= 0; i--)
      if (screen[i] == temp) check = 1;
    if (check) continue;
    screen[p] = temp;
    p++;
  }
  if (p > k) {
    printf("%d\n", k);
    for (int i = p - 1; i >= p - k; i--) printf("%d ", screen[i]);
  } else {
    printf("%d\n", p);
    for (int i = p - 1; i >= 0; i--) printf("%d ", screen[i]);
  }
}
