#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, M, D;
  cin >> n >> k >> M >> D;
  long long best = 0, j, h = n / M;
  while (1) {
    j = h / k + (h % k > 0);
    if (j > D) break;
    if (min(M, n / h) * j > best) best = min(M, n / h) * j;
    if (h % k < k / 5 + 1 && h % k != 0) break;
    h += (k - h % k) * (h % k > 0) + 1;
  }
  cout << best;
  return 0;
}
