#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-3;
const int MAXN = 2e5 + 10;
const int MAXM = 2e6 + 10;
const long long mod = 1e9 + 7;
long long n, k, m, d;
bool judge(long long x) {
  for (long long i = 1; i <= d; i++) {
    long long num = x / i;
    if (x % i) num++;
    if (num > m) continue;
    if ((i - 1) * num <= (n - num) / k) return true;
  }
  return false;
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &k, &m, &d);
  long long l = 1, r = n;
  long long ans;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (judge(mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  printf("%lld\n", ans);
  return 0;
}
