#include <bits/stdc++.h>
using namespace std;
long long int n, m;
long long int arr[300000];
vector<long long int> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int TESTS, q, a, b, l, r, c, k, p, h, w, x, y, z, xs, ys, t, f;
  long double d;
  TESTS = 1;
  while (TESTS--) {
    cin >> n >> p;
    long long int maxi = 0;
    for (long long int i = 0; i <= n - 1; i++)
      cin >> arr[i], maxi = max(maxi, arr[i]);
    sort(arr, arr + n);
    for (long long int i = 1; i <= maxi; i++) {
      long long int num = 1;
      x = i;
      y = 0;
      while (y < n) {
        long long int ind = upper_bound(arr, arr + n, x) - arr;
        num *= ind - y;
        num %= p;
        x++;
        y++;
      }
      if (num) ans.push_back(i);
    }
    cout << ans.size() << "\n";
    for (auto it : ans) cout << it << " ";
  }
  return 0;
}
