#include <bits/stdc++.h>
using namespace std;
void co() { cout << '\n'; }
template <typename T, typename... Ts>
void co(const T& value, const Ts&... values) {
  cout << value << ' ';
  co(values...);
}
long long n, k, M, D;
long long ans = 0;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> M >> D;
  for (long long i = (1); i <= (D); i++) {
    if (log(i - 1) + log(k) > log(n) + 1) break;
    long long X = n / (1LL * (i - 1) * k + 1);
    X = min(X, M);
    ans = max(ans, X * i);
  }
  cout << ans << '\n';
}
