#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 7;
const int nmax = 1e5 + 10;
const int eps = 1e-8;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  long long n, k, m, d;
  cin >> n >> k >> m >> d;
  long long ans = -inf;
  long long nibo;
  for (long long i = 1; i <= d && (k * i - k + 1) <= n; i++) {
    nibo = n / (i * k - k + 1);
    if (nibo > m) nibo = m;
    ans = max(ans, nibo * i);
  }
  cout << ans << "\n";
  return 0;
}
