#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, inf = 1e9 + 7, M = 707;
long long n, k, i, j;
long long m, d;
bool check(long long mid, long long turn) {
  long long rem = n - mid * k * turn;
  return rem >= mid;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, a, b, ans = 0, mx, mn, mid;
  cin >> n >> k >> m >> d;
  for (i = 0; i < min(d, n / k + 1); i++) {
    if (i)
      mx = min(n / (k * i), m);
    else
      mx = min(n, m);
    mn = n / (k * (i + 1));
    ans = max(ans, i * mx);
    while (mn <= mx) {
      mid = mn + mx >> 1;
      if (check(mid, i))
        ans = max(ans, i * mid + mid), mn = mid + 1;
      else
        mx = mid - 1;
    }
  }
  cout << ans;
}
