#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, d = 0;
  cin >> n >> k;
  int a[n];
  int b[k];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    int flag = 0;
    for (int j = 0; j < d; j++) {
      if (a[i] == b[j]) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      continue;
    }
    if (d == k) {
      for (int g = 0; g < d - 1; g++) {
        b[g] = b[g + 1];
      }
      b[k - 1] = a[i];
    }
    if (d < k) {
      b[d] = a[i];
      d++;
    }
  }
  int count = 0;
  for (int i = 0; i < d; i++) {
    count++;
  }
  cout << count << endl;
  for (int i = d - 1; i >= 0; i--) {
    cout << b[i] << " ";
  }
  return 0;
}
