#include <bits/stdc++.h>
using namespace std;
template <typename _Temp>
void pr(_Temp x, bool fl = false) {
  cout << x << endl;
  if (fl) exit(0);
}
template <typename _Temp>
void pr(_Temp x, _Temp y, bool fl = false) {
  cout << x << " " << y << endl;
  if (fl) exit(0);
}
template <typename _Temp>
void pr(_Temp x[], long long n, bool fl = false) {
  for (long long i = 1; i <= n; i++) cout << x[i] << (i == n ? '\n' : ' ');
  if (fl) exit(0);
}
long long n, p, a[20007], b[20007];
long long cnt = 0, ans[20007];
signed main() {
  ios::sync_with_stdio(false);
  long long test_case = 1;
  while (test_case--) {
    long long n, p, mx = LLONG_MIN;
    cin >> n >> p;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i], mx = max(mx, a[i]);
      for (long long j = a[i]; j <= 10 * 2000; j++) b[j]++;
    }
    for (long long x = 1; x <= mx; x++) {
      for (long long i = 1; i <= n; i++) {
        long long now;
        now = b[x + i - 1] - i + 1;
        if (now % p == 0) goto nxt;
      }
      ans[++cnt] = x;
    nxt:;
    }
    pr(cnt);
    for (long long i = 1; i <= cnt; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
