#include <bits/stdc++.h>
using namespace std;
int64_t n, k, m, d, res = 0;
int64_t Binary(int64_t tt) {
  int64_t rs = -1, l = 1, r = m;
  while (l <= r) {
    int64_t mid = (l + r) / 2;
    int64_t p = n / mid;
    int64_t t = p / k + (p % k != 0);
    if (t == tt) {
      rs = mid;
      l = mid + 1;
    } else if (t < tt)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return rs;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> m >> d;
  for (int64_t i = 1; i <= d; i++) {
    int64_t tmp = Binary(i);
    if (tmp != -1) res = max(res, tmp * i);
  }
  cout << res;
}
