#include <bits/stdc++.h>
using namespace std;
int a[1000];
int main() {
  int n, k;
  cin >> n >> k;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int v;
    cin >> v;
    bool flag = true;
    for (int j = sum >= k ? sum - k + 1 : 1; j <= sum; j++) {
      if (v == a[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      a[++sum] = v;
    }
  }
  cout << (sum >= k ? k : sum) << endl;
  for (int i = sum; i >= (sum >= k ? sum - k + 1 : 1); i--) {
    cout << a[i] << " ";
  }
  return 0;
}
