#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, M, D;
  cin >> n >> k >> M >> D;
  vector<long long int> v;
  for (long long int d = 1; d <= D; d++) {
    long long int x1 = n / (k * d + 1), x2 = n / (k * d - k + 1);
    long long int x_min = min(x1, x2), x_max = max(x1, x2);
    if (k * d > 1000000000000000000) break;
    if (x_max <= M) {
      v.push_back(d * x_max);
    } else if (x_min <= M && x_max > M) {
      v.push_back(d * M);
    }
  }
  long long int x_final = 0;
  for (long long int i = 0; i < v.size(); i++) {
    x_final = max(x_final, v[i]);
  }
  cout << x_final;
  return 0;
}
