#include <bits/stdc++.h>
const long long mod = 1e9 + 7, maxn = 1000010;
const double eps = 1e-8, pi = acos(-1.0);
const long long inf = 0x7f7f7f7f;
using namespace std;
long long a[maxn], b[maxn], v[maxn];
string s;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, p;
  cin >> n >> p;
  for (register long long i = (1); i <= (n); ++i) cin >> a[i];
  vector<long long> ans;
  sort(a + 1, a + 1 + n);
  for (register long long i = (0); i <= (2010); ++i) {
    long long flag = 1;
    for (register long long j = (1); j <= (n); ++j) {
      long long x = upper_bound(a + 1, a + 1 + n, i + j - 1) - a;
      long long res = x - j;
      if (res >= p || res == 0) {
        flag = 0;
        break;
      }
    }
    if (flag) ans.push_back(i);
  }
  cout << ans.size() << endl;
  for (auto i : ans) cout << i << " ";
  cout << endl;
}
