#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = 0; i < v.size(); i++) os << v[i] << " ";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (typename set<T>::iterator it = v.begin(); it != v.end(); it++)
    os << *it << " ";
}
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
int main() {
  long long n, k, m, d, ans = 0;
  cin >> n >> k >> m >> d;
  for (int i = (0); i <= (min(d - 1, n)); i++) {
    long long R = n / (i * k + 1);
    long long L = n / (i * k + k + 1);
    if (m > L && m <= R) {
      ans = max(ans, m * (i + 1));
    }
    if (R <= m) {
      ans = max(ans, R * (i + 1));
    }
    if (n < i * k + 1) break;
  }
  cout << ans;
}
