#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, M, D;
  scanf("%lld %lld %lld %lld", &n, &k, &M, &D);
  long long ans = 0;
  for (long long d = 1; d <= D; ++d) {
    long long l = 0, r = M + 1;
    while (l < r - 1) {
      long long m = (l + r) / 2;
      double t = (double)k * (double)m * (d - 1) + m;
      if (t <= (double)n)
        l = m;
      else
        r = m;
    }
    ans = max(ans, l * d);
  }
  printf("%lld\n", ans);
  return 0;
}
