#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m, d;
  cin >> n >> k >> m >> d;
  long long mx = 0;
  long long cnt = n / m;
  cnt = ceil((long double)cnt / k);
  mx = (m * cnt);
  for (long long i = 1; i <= d; i++) {
    long long s = (i - 1) * k + 1, e = i * k, mid;
    long long st = s, en = e;
    while (s <= e) {
      mid = (s + e) / 2;
      if (n / mid <= m)
        e = mid - 1;
      else
        s = mid + 1;
    }
    mid = s;
    long long ans = n / mid;
    if (ans == 0) break;
    long long chck = n / ans;
    if (chck < st || chck > en) continue;
    mx = max(mx, i * ans);
  }
  cout << mx;
  return 0;
}
