#include <bits/stdc++.h>
using namespace std;
long long n, k, M, D;
long long cnt(long long x) {
  long long MX, people;
  people = k * (x - 1) + 1;
  MX = n / people;
  if (MX > M) MX = M;
  return MX * x;
}
int main(void) {
  long long i, j, ans;
  scanf("%lld %lld %lld %lld", &n, &k, &M, &D);
  ans = 0;
  for (i = 1; i <= D; i++) {
    if ((i - 1) > (2e18) / k) break;
    ans = max(ans, cnt(i));
  }
  printf("%lld\n", ans);
}
