#include <bits/stdc++.h>
using namespace std;
long long n, k, M, D, N, sol, x, mid, f, l, T;
long long up(long long a, long long b) {
  long long tmp = a / b;
  if (a % b != 0) tmp = tmp + 1ll;
  return tmp;
}
long long rep(long long a) {
  long long tmp = n / a;
  tmp = up(tmp, k);
  return tmp;
}
int main() {
  cin >> n >> k >> M >> D;
  sol = rep(M) * M;
  for (long long p = 2ll; p <= D; p++) {
    f = 1ll, l = M;
    mid = (f + l + 1ll) / 2;
    T = -1;
    while (l > f) {
      mid = (f + l + 1ll) / 2;
      if (rep(mid) == p && rep(mid + 1ll) != p) {
        T = mid;
        break;
      }
      if (rep(mid) >= p) {
        f = mid;
      } else if (rep(mid) < p) {
        l = mid - 1ll;
      }
      if (l - f <= 1) {
        if (rep(f) == p && rep(l + 1ll) > p) {
          T = f;
          break;
        }
        if (rep(l) == p && rep(l + 1ll) > p) {
          T = l;
          break;
        }
      }
    }
    if (T != -1) {
      x = T;
      T = rep(x) * x;
      sol = max(sol, T);
    }
  }
  cout << sol;
  return 0;
}
