#include <bits/stdc++.h>
template <class T, class F, class C>
auto binary_search(T l, T r, F func, C cmp) -> T;
auto division(int64_t n, int64_t d) -> int64_t { return n / d; }
int main() {
  int64_t n, k, m, d;
  std::cin >> n >> k >> m >> d;
  int64_t answer = 0;
  for (int64_t q_k = 1; q_k <= d; ++q_k) {
    int64_t x_max = binary_search(
        int64_t(1), m + 1,
        [n, q_k, k](int64_t x) { return (division(n, x) - 1) / k + 1 >= q_k; },
        [](int64_t l, int64_t r) { return l + 1 >= r; });
    if ((division(n, x_max) - 1) / k + 1 != q_k) {
      continue;
    }
    answer = std::max(answer, x_max * q_k);
  }
  std::cout << answer << '\n';
  return 0;
}
template <class T, class F, class C>
auto binary_search(T l, T r, F func, C cmp) -> T {
  bool dir = func(l);
  for (auto mid = (l + r) / 2; !cmp(l, r); mid = (l + r) / 2) {
    (func(mid) == dir ? l : r) = mid;
  }
  return l;
}
