#include <bits/stdc++.h>
using namespace std;
string tostr(int n) {
  stringstream rr;
  rr << n;
  return rr.str();
}
long long power(long long a, long long b) {
  return b == 0 ?: a * power(a, b - 1);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  while (cin >> n >> k) {
    int arr[n + 5];
    vector<int> v;
    set<int> st;
    for (int i = 0; i < n; i++) cin >> arr[i];
    for (int i = 0; i < n; i++) {
      if (v.size() < k) {
        if (find(v.begin(), v.end(), arr[i]) != v.end()) continue;
        v.push_back(arr[i]);
        st.insert(arr[i]);
      } else {
        if (find(v.begin(), v.end(), arr[i]) != v.end())
          continue;
        else {
          int j;
          for (j = 1; j < v.size(); j++) {
            v[j - 1] = v[j];
          }
          v[j - 1] = arr[i];
        }
      }
    }
    cout << v.size() << "\n";
    for (int i = v.size() - 1; i >= 0; i--) cout << v[i] << " ";
    cout << "\n";
  }
  return 0;
}
