#include <bits/stdc++.h>
using namespace std;
long long int getmin(long long int a, long long int b) {
  if (a <= b)
    return a;
  else
    return b;
}
int main() {
  long long int n, k, m, d, b, max, z, c, i, j, p, q;
  cin >> n >> k >> m >> d;
  max = -1;
  for (i = 1; i <= d; i++) {
    if ((n / i) < k) break;
    b = m;
    c = n / ((i - 1) * k + 1);
    b = getmin(b, c);
    if (b == 0) continue;
    z = i * b;
    if (b <= m && z > max) max = z;
  }
  cout << max << "\n";
  return 0;
}
