#include #define rep(i,a,b) for(int i=int(a);i> A >> B >> C >> D; for(int i = A;i >= 0;i--){ if(i * C <= B && i + i * C <= D){ cout << i << endl; return 0; } } }