def main1(n,k,h,y): ary=[n,k,h] ary.sort() a,b,c=ary g=gcd(a,b) na,nb=a//g,b//g now=0 ans=0 while now<=y: yy=y-now now+=c if yy%g!=0:continue yy=yy//g if yy==0: ans+=1 continue if yy