#include <bits/stdc++.h>
using namespace std;
int BiggestPowerOf2Less(int x) {
  for (int i = 21; i > 0; i--) {
    if (x & (1 << i)) return i;
  }
}
bool isPerfectLongCat(int x) {
  for (int i = 0; i < 23; i++)
    if (x == (1 << i) - 1) return true;
  return false;
}
int isPowerOf2(int x) {
  for (int i = 0; i < 21; i++) {
    if (x == (1 << i)) return i;
  }
  return -1;
}
unsigned long gcd(unsigned long x, unsigned long y) {
  if (!x) return y;
  if (!y) return x;
  return x > y ? gcd(x % y, y) : gcd(x, y % x);
}
unsigned long lcm(unsigned long x, unsigned long y) {
  return (x * y) / gcd(x, y);
}
auto main() -> int {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  unsigned long long int n, k, M, D, res = 0;
  cin >> n >> k >> M >> D;
  unsigned long long int c, p;
  if (D == 1 || n == k || k > n) {
    cout << M;
    exit(0);
  }
  if (M == 1) {
    cout << min(n / k, D);
    exit(0);
  }
  for (unsigned long long int i = 1; i <= D; i++) {
    p = k * (i - 1) + 1;
    c = n / p;
    if (p > n) continue;
    res = max(res, min(c, M) * i);
  }
  cout << res;
}
