#include <bits/stdc++.h>
using namespace std;
int calPermutation(int x, vector<int> arr, int n, int p) {
  int i;
  int ans = 1;
  vector<int> temp;
  int len = 0;
  int lastInd = 0;
  for (i = 0; i < n; i++) {
    while (lastInd < n && arr[lastInd] <= x) {
      len++;
      lastInd++;
    }
    if (len % p == 0) return 0;
    len--;
    x++;
  }
  return 1;
}
int main() {
  int n, p, i, x;
  vector<int> arr;
  cin >> n >> p;
  for (i = 0; i < n; i++) {
    int l;
    cin >> l;
    arr.push_back(l);
  }
  sort(arr.begin(), arr.end());
  int l, r;
  l = arr[0];
  r = arr[n - 1];
  vector<int> ans;
  for (x = l; x < r; x++) {
    int xl = calPermutation(x, arr, n, p);
    if (xl) {
      ans.push_back(x);
    }
  }
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
}
