#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
const int mod = 1e9 + 7;
void solve() {
  int n, p;
  cin >> n >> p;
  vector<int> a(n), per;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int x = 1; x <= 2000; x++) {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      int lb = upper_bound(a.begin(), a.end(), x + i) - a.begin();
      lb--;
      int y = lb + 1 - i;
      if (y % p == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      per.push_back(x);
    }
  }
  cout << per.size() << endl;
  for (auto u : per) cout << u << " ";
  cout << endl;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
