#include <bits/stdc++.h>
using namespace std;
long long n, k, d, m;
bool bad(long long D, long long x, long long k) {
  if (D - 1 > n / x / k) {
    return 1;
  }
  return 0;
}
int main() {
  cin >> n >> k >> m >> d;
  long long ans = -1;
  for (long long D = d; D >= 1; D--) {
    long long L = 1, R = m, x = -1;
    while (L <= R) {
      long long mid = (L + R) / 2;
      if (bad(D, mid, k) || mid + (D - 1) * k * mid > n) {
        R = mid - 1;
      } else {
        x = mid;
        L = mid + 1;
      }
    }
    if (x == -1) {
      continue;
    }
    long long rem = n - (x + (D - 1) * k * x);
    if (rem >= k * x && d == D) {
      continue;
    }
    ans = max(ans, x * D);
  }
  assert(ans != -1);
  cout << ans << '\n';
  return 0;
}
