#include "bits/stdc++.h" using namespace std; void solve() { int a, b, c, d, ans = 0; for (int x = 0; x <= a; x++) { if (x*c <= b && x*(c+1) <= d) { ans = x*(c+1); } } cout << ans << endl; } int main(void) { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }