#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k, m, D;
  cin >> n >> k >> m >> D;
  long long ans = 0;
  for (long long d = 1; d <= D; d++) {
    long long x = n / ((d - 1) * k + 1);
    if (x == 0) break;
    x = min(x, m);
    ans = max(ans, x * d);
  }
  cout << ans << "\n";
}
