#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void pp(T... args) {
  ((cout << args << " "), ...);
  cout << "\n";
}
template <typename... T>
void po(T... args) {
  ((cout << args << " "), ...);
  cout << "";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int test = 1;
  for (int tt = 1; tt <= test; tt++) {
    long long int n, p;
    cin >> n >> p;
    long long int a[n], ma = 0, mi = 1e9;
    map<long long int, long long int> mp;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      ma = max(a[i], ma);
      mi = min(a[i], mi);
      mp[a[i]]++;
    }
    sort(a, a + n);
    vector<long long int> ans;
    for (int i = 1; i <= ma; i++) {
      int cnt = 0;
      int ch = 1;
      for (int j = 1, k = 0; j <= n; j++) {
        while (k < n && a[k] <= i + j - 1) {
          k++;
          cnt++;
        }
        if (cnt % p == 0) {
          ch = 0;
          break;
        }
        cnt -= 1;
      }
      if (ch == 1) ans.push_back(i);
    }
    pp(ans.size());
    for (auto i : ans) {
      po(i);
    }
    cout << endl;
  }
  return 0;
}
