#include <iostream>
#define int long long
using namespace std;
int n, k, m, d;
signed main()
{
cin >> n >> k >> m >> d;
int res = 0;
for(int i = 1; i <= d && (i - 1) * k + 1 <= n; i ++)
{
int l = 0, r = m + 1;
while(l + 1 < r)
{
int mid = l + r >> 1;
if(n / mid >= (i - 1) * k + 1) l = mid;
else r = mid;
}
if(d * k >= n / l)
res = max(res, i * l);
}
cout << res << endl;
}