#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, p;
  cin >> n >> p;
  vector<int> v(n);
  vector<int> v1(n);
  for (int i = 0; i < (int)(n); ++i) {
    cin >> v[i];
    v1[i] = v[i];
  }
  sort(v1.begin(), v1.end());
  vector<int> ans;
  int min1 = v1[0], max1 = v1.back();
  for (int i = min1; i <= max1; i++) {
    int temp = i;
    int prev = 0;
    vector<int> temp1(v1);
    bool is = true;
    for (int j = 0; j < n; j++) {
      auto it = upper_bound(temp1.begin(), temp1.end(), temp);
      int ele = (it - temp1.begin()) - prev;
      if (ele == 0) {
        is = false;
        break;
      }
      if (ele % p == 0) {
        is = false;
        break;
      }
      prev++;
      temp++;
    }
    if (is) ans.push_back(i);
  }
  cout << int((ans).size()) << "\n";
  for (auto i : ans) {
    cout << i << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
