#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  vector<long long int> v, vans;
  for (int a = 0; a < n; a++) {
    long long int kk;
    cin >> kk;
    v.push_back(kk);
  }
  sort(v.begin(), v.end());
  long long int ans = 0;
  long long int x, y, z, xx, yy, zz;
  for (long long int a = 1; a <= 2001; a++) {
    z = 1;
    for (long long int b = 0; b < n; b++) {
      x = a + b;
      y = upper_bound(v.begin(), v.end(), x) - v.begin();
      y -= b;
      if (y % k == 0 || y <= 0) {
        z = 0;
        break;
      }
    }
    if (z != 0) {
      vans.push_back(a);
    }
  }
  cout << vans.size() << "\n";
  for (int a = 0; a < vans.size(); a++) cout << vans[a] << " ";
  cout << "\n";
  return 0;
}
