#include <bits/stdc++.h>
using namespace std;
long long n, k, m, d, mx;
int main() {
  cin >> n >> k >> m >> d;
  d = min(d - 1, (n + k - 1) / k);
  while (d >= 0) {
    long long x = (n + 1);
    if (x % (1 + d * k) == 0)
      x = x / (1 + d * k);
    else
      x = x / (1 + d * k) + 1;
    if (x > m) x = m;
    while (x * d * k + x > n) x--;
    if (x * (d + 1) > mx) mx = x * (d + 1);
    d--;
  }
  cout << mx;
  return 0;
}
