#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = std::vector<T>;
bool __hack = std::ios::sync_with_stdio(false);
auto __hack1 = cin.tie(nullptr);
namespace template_util {
constexpr int bytecount(uint64_t x) { return x ? 1 + bytecount(x >> 8) : 0; }
template <int N>
struct bytetype {};
template <uint64_t N>
struct minimal_uint : bytetype<bytecount(N)> {};
}  // namespace template_util
template <class T>
T next(istream& in) {
  T ret;
  in >> ret;
  return ret;
}
template <class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}
template <class T>
void outVec(ostream& out, const vector<T>& v) {
  if (v.empty()) {
    out << "\n";
    return;
  }
  out << v[0];
  for (size_t i = 1; i < v.size(); ++i) {
    out << ' ' << v[i];
  }
  out << "\n";
}
void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto p = next<int>(in);
  auto a = next_vec<int>(in, n);
  sort(a.begin(), a.end());
  vec<int> xs;
  for (int x = 1; x < a.back(); ++x) {
    int opened = 0;
    int left = n;
    int ptr = 0;
    int X = x;
    int res = 1;
    while (true) {
      while (ptr < n) {
        if (a[ptr] <= X) {
          ++ptr;
          ++opened;
          --left;
        } else {
          break;
        }
      }
      if (opened == 0) {
        if (left == 0) {
          break;
        }
        res = 0;
        break;
      }
      res = (res * opened) % p;
      ++X;
      --opened;
    }
    if (res) {
      xs.push_back(x);
    }
  }
  out << xs.size() << "\n";
  outVec(out, xs);
}
int main() {
  solve(cin, cout);
  return 0;
}
