#include <bits/stdc++.h>
unsigned long long mx;
int main() {
  unsigned long long n, k, m, d;
  std::cin >> n >> k >> m >> d;
  if (d == 1)
    std::cout << m << "\n";
  else {
    for (int i = 1; i <= d; i++) {
      unsigned long long c = i - 1;
      c = c * k;
      c = c + 1;
      unsigned long long x = n / c;
      if (x == 0) break;
      c = std::min(m, x);
      mx = std::max(mx, c * i);
    }
    std::cout << mx << '\n';
  }
  return 0;
}
