#include <bits/stdc++.h>
#pragma GCC optimize "03"
const long long int MOD = 1e9 + 7;
const long long int INF = 1011111111;
const long long int LLINF = 1000111000111000111LL;
const long double EPS = 1e-10;
const long double PI = 3.14159265358979323;
using namespace std;
long long int power(long long int base, long long int exponent) {
  long long int ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base);
    base = (1LL * base * base);
    exponent >>= 1;
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m, i, j, k, p;
  cin >> n >> p;
  vector<long long int> v(n);
  map<long long int, long long int> mp;
  for (i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    v[i] = x;
    mp[x]++;
  }
  sort(v.begin(), v.end());
  vector<long long int> ans;
  for (long long int x = v[0]; x <= v[n - 1]; x++) {
    bool ok = true;
    long long int cur = x;
    long long int ctr = 0;
    while (cur < x + n) {
      long long int vals = (upper_bound(v.begin(), v.end(), cur) - v.begin());
      vals -= ctr;
      if (vals <= 0 || vals % p == 0) ok = false;
      cur++;
      ctr++;
    }
    if (ok) ans.push_back(x);
  }
  cout << (long long int)ans.size() << '\n';
  for (auto p : ans) cout << p << " ";
  cerr << '\n'
       << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
}
