#include <bits/stdc++.h>
using namespace std;
int a[10005], p, n, ans[10005], ansn;
int main() {
  int _;
  while (~scanf("%d%d", &n, &p)) {
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
    }
    sort(a + 1, a + 1 + n);
    ansn = 0;
    for (int x = 1; x <= 2000; ++x) {
      int r = 1, cur = x;
      int have = 0;
      for (int i = 1; i <= n; ++i) {
        while (r <= n && a[r] <= cur) ++r;
        if (r <= i) {
          have = 1;
          break;
        }
        if ((r - i) % p == 0) {
          have = 1;
          break;
        }
        ++cur;
      }
      if (!have) ans[++ansn] = x;
    }
    printf("%d\n", ansn);
    for (int i = 1; i <= ansn; ++i) {
      printf("%d%c", ans[i], i == ansn ? '\n' : ' ');
    }
  }
  return 0;
}
