#include <bits/stdc++.h>
using namespace std;
long long n, k, m, d;
double pq;
long long fn(long long x) {
  if (pq + log10(x) > 18.1) return 1;
  long long den = (k * x);
  long long tim = n / den;
  if (n - (tim * den) >= x) return tim + 1;
  return tim;
}
long long bs(long long alpha) {
  long long lo = 1, hi = m;
  long long ans = -1;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    long long uu = fn(mid);
    if (uu == alpha) {
      ans = max(ans, mid);
      lo = mid + 1;
    } else if (uu > alpha) {
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  return ans;
}
int main() {
  cin >> n >> k >> m >> d;
  pq = log10(k);
  long long ans = 0;
  for (int i = d; i >= 1; i--) {
    long long ii = bs(i);
    if (ii != -1) {
      ans = max(ans, ii * i);
    }
  }
  cout << ans;
}
