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