#include <bits/stdc++.h>
using namespace std;
long long n, k, m, d;
long long p(long long x) { return (n / x + k - 1) / k; }
int main() {
  cin >> n >> k >> m >> d;
  long long ans = 0;
  for (long long v = 1; v <= d; v++) {
    long long l = 1, r = m, mid;
    while (l <= r) {
      mid = (l + r) / 2;
      if (p(mid) < v)
        r = mid - 1;
      else
        l = mid + 1;
    }
    if (r > 0 && p(r) == v) ans = max(ans, v * r);
  }
  cout << ans << endl;
}
