#include<bits/stdc++.h> using namespace std; #define ll long long ll n,k,M,D,anss; ll calc(ll x){ ll tmp=(n/x-1)/k+1; return tmp; } int main(){ cin>>n>>k>>M>>D; for(ll i=1;i<=D;i++){ ll l=1,r=M,mid,ans=0; while(l<=r){ mid=l+r>>1; ll t=calc(mid); if(t>=i) ans=mid,l=mid+1; else r=mid-1; } if(ans!=0) anss=max(anss,ans*i); } cout<<anss<<endl; }