#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a > b) {
    long long tmp = a;
    a = b;
    b = tmp;
  }
  while (a) {
    long long tmp = b % a;
    b = a;
    a = tmp;
  }
  return b;
}
int main() {
  ios::sync_with_stdio(0);
  int t = 1;
  while (t--) {
    long long n, p, i, j, x, mx = -1;
    cin >> n >> p;
    vector<long long> a(n);
    for (i = 0; i < n; i++) {
      cin >> a[i];
      mx = max(mx, a[i]);
    }
    vector<long long> h(2001, 0);
    for (i = 0; i < n; i++) h[a[i]]++;
    for (i = 1; i <= 2000; i++) h[i] += h[i - 1];
    vector<long long> ans;
    for (x = 1; x < mx; x++) {
      long long flag = 1, ct = 0, total = 1;
      for (i = x; i < x + n; i++) {
        long long cur;
        if (i >= mx)
          cur = h[mx];
        else
          cur = h[i];
        if (cur - ct <= 0) {
          flag = 0;
          break;
        }
        if (((cur - ct) % p) == 0) {
          flag = 0;
          break;
        }
        ct++;
      }
      if (flag) ans.push_back(x);
    }
    long long sz = ans.size();
    cout << sz << endl;
    for (i = 0; i < sz; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
