#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
const long long SZ = 4e5 + 5;
const long long mod = 1e9 + 7;
long long n, p;
long long a[SZ];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long cs = 0, tc = 1, x, y, z, i, j, k, g, q, ans = 0, sum = 0, c = 0,
            t = 0;
  string s, s1, s2;
  cin >> n >> p;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  long long mn = a[n], mx = a[n];
  for (i = a[1]; i <= a[n]; i++) {
    x = i;
    for (j = 1; j <= n; j++) {
      if (a[j] <= x)
        x++;
      else
        break;
    }
    if (j == n + 1) {
      mn = i;
      break;
    }
  }
  vector<long long> gd;
  for (i = mn; i <= mx; i++) {
    x = i;
    bool ok = 1;
    k = 1;
    for (j = 1; j <= n; j++) {
      while (1) {
        if (a[k] > x) {
          k--;
          break;
        }
        k++;
        if (k > n) {
          k--;
          break;
        }
      }
      c = k - (j - 1);
      x++;
      if (c % p == 0) {
        ok = 0;
        break;
      }
    }
    if (ok) gd.push_back(i);
  }
  cout << gd.size() << "\n";
  for (auto v : gd) cout << v << " ";
  cout << "\n";
  return 0;
}
