#include <bits/stdc++.h>
using namespace std;
template <class T>
void smin(T &a, T b) {
  a = min(a, b);
}
template <class T>
void smax(T &a, T b) {
  a = max(a, b);
}
template <class T>
T min(vector<T> &a) {
  return *min_element(a.begin(), a.end());
}
template <class T>
T max(vector<T> &a) {
  return *max_element(a.begin(), a.end());
}
template <class T>
void print(vector<T> &a, string sep) {
  for (T el : a) cout << el << sep;
  cout << endl;
}
void solve() {
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  ;
  sort(a.begin(), a.end());
  int minx = a[0];
  int maxx = a[n - 1];
  vector<int> xs;
  for (int X = minx; X <= maxx; X++) {
    int x = X;
    vector<long long> k(n, 0);
    int ctr = 0;
    for (int i = 0; i < n; i++) {
      while (ctr < n && a[ctr] <= x + i) {
        ctr++;
      }
      k[i] = ctr - i;
    }
    bool ok = true;
    for (int i = 0; i < n; i++) {
      if (k[i] % p == 0) {
        ok = false;
      }
    }
    if (ok) xs.push_back(X);
  }
  cout << xs.size() << endl;
  print(xs, " ");
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
