#include <bits/stdc++.h>
using namespace std;
const int N = 210;
const int mod = 1e9 + 7;
int i[N], q[N], head, tail;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, x;
  head = tail = 0;
  cin >> n >> k;
  for (int j = 0; j < n; j++) {
    cin >> x;
    bool f = 1;
    for (int l = head; l < tail; l++)
      if (q[l] == x) {
        f = 0;
        break;
      }
    if (f) q[tail++] = x;
    if (tail - head == k + 1) head++;
  }
  cout << tail - head << endl;
  for (int j = tail - 1; j >= head; j--) cout << q[j] << ' ';
}
