#include <bits/stdc++.h>
using namespace std;
void crash() {
  int ll = 0;
  cout << 1 / ll;
}
const int INF = 1 << 30;
const int MAXN = 3010;
unsigned long long N, K, M, D;
void Read() { cin >> N >> K >> M >> D; }
void Solve() {
  unsigned long long ans = 0;
  for (unsigned long long d = 1; d <= D; ++d) {
    double tmp = 1.0 * K * (d - 1) + 1;
    if (tmp > N) continue;
    unsigned long long c = K * (d - 1) + 1;
    unsigned long long x = N / c;
    x = min(x, M);
    unsigned long long left = N - x * K * (d - 1) - x;
    if (left >= x * K) continue;
    unsigned long long cur = d * x;
    ans = max(ans, cur);
  }
  cout << (long long)ans << endl;
}
int main() {
  Read();
  Solve();
  return 0;
}
