#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, num;
  cin >> n >> k;
  vector<long long int> initial;
  list<long long int> result;
  for (int i = 0; i < n; i++) {
    cin >> num;
    initial.push_back(num);
  }
  for (int i : initial) {
    int flag = 0;
    for (int j : result) {
      if (i == j) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      if (result.size() == k) result.pop_back();
      result.push_front(i);
    }
  }
  cout << result.size() << "\n";
  for (int i : result) cout << i << " ";
  return 0;
}
