#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, p;
  cin >> n >> p;
  vector<int> a(n), ans;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int x = 1; x <= 2000; x++) {
    bool isGood = true;
    for (int i = 0; i < n; i++) {
      int k = upper_bound(a.begin(), a.end(), x + i) - a.begin() - i;
      if (k % p == 0) {
        isGood = false;
        break;
      }
    }
    if (isGood) ans.push_back(x);
  }
  cout << ans.size() << endl;
  for (int k : ans) {
    cout << k << ' ';
  }
  cout << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
