#include using namespace std; int main(){ int N,M,P,Q; cin>>N>>M>>P>>Q; //YD 1年に落とす葉の数 int YD=0; YD=M*12+Q*M; //cnt 経過月数 int cnt=0; cnt+=(N/YD)*12; //DD 年単位で葉を落とした後の余った葉の数 int DD=0; DD=N-YD*(N/YD); //剰余月数 int MM=0; while(DD>0){ cnt++; MM++; //cout<=P && MM<=P+Q-1){ DD-=(2*M); } else{ DD-=M; } if(MM==12){ MM=0; } } cout<