#include <bits/stdc++.h>
using namespace std;
long long n, k, m, d;
long long times(long long x) { return (n / x + k - 1) / k; }
long long calc(long long x) { return times(x) * x; }
long long find(long long x, long long l, long long r) {
  long long res = -1;
  while (l <= r) {
    long long g = (l + r) >> 1;
    long long t = times(g);
    if (t >= x) {
      res = g;
      l = g + 1;
    } else
      r = g - 1;
  }
  return res;
}
int main() {
  cin >> n >> k >> m >> d;
  long long res = 0;
  for (long long i = 1; i <= d; i++) {
    long long x = find(i, 1, m);
    if (x != -1 && times(x) == i) res = max(res, x * i);
  }
  cout << res;
}
