#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, i, j, l, f = 0, m, g = 0, size;
  cin >> n >> k;
  long long int arr[n];
  long long int temp[k];
  for (i = 0; i < n; i++) cin >> arr[i];
  for (i = 0; i < n; i++) {
    if (f == k) break;
    for (j = 0; j < f; j++) {
      if (temp[j] == arr[i]) {
        g++;
        break;
      }
    }
    if (g == 0)
      temp[f++] = arr[i];
    else
      g = 0;
  }
  for (j = f; j < n; j++) {
    g = 0;
    for (l = 0; l < f; l++) {
      if (temp[l] == arr[j]) {
        g++;
        break;
      }
    }
    if (g == 0) {
      if (f < k)
        temp[f++] = arr[j];
      else {
        for (m = 1; m < f; m++) temp[m - 1] = temp[m];
        temp[m - 1] = arr[j];
        continue;
      }
    }
  }
  cout << f << endl;
  for (i = f - 1; i >= 0; i--) cout << temp[i] << " ";
  cout << endl;
  return 0;
}
