#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 5;
long long n, m, x, y, p, q, k, a, b, c, ans, r, kk, dd, ss, ii = 0;
int main() {
  cin >> n >> p;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long sum = 0, ff;
  vector<long long> res;
  for (long long i = a[0]; i <= a[n - 1]; i++) {
    ff = 1;
    for (long long j = 0; j < n; j++) {
      int fx = upper_bound(a.begin(), a.end(), i + j) - a.begin() - j;
      if (fx % p == 0) {
        ff = 0;
        break;
      }
    }
    if (ff) res.push_back(i);
  }
  cout << res.size() << endl;
  for (long long i = 0; i < res.size(); i++) cout << res[i] << " ";
  cout << endl;
}
