#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a c Int solve1(Int a,Int b,Int c,Int d){ if(b<2) return INF; if(d==0) return ac&&a!=c?0:INF; Int res=0; if(a>=b){ Int x=(a-b)/d; a-=x*d;res+=x; if(a>=b) a-=d,res++; } if(c>=b){ Int x=(c-b)/d; c-=x*d;res+=x; if(c>=b) c-=d,res++; } chmax(a,0); chmax(c,0); // a < b > c assert(ac); if(a==0&&c==0) return INF; if(a!=c) return res; return res+1; } // a > b < c Int solve2(Int a,Int b,Int c,Int d){ if(min(a,c)<=0) return INF; if(d==0) return a>b&&bb&&b b < c if(a!=c) return res; return solve2(a-d,b,c,d)+res+1; } signed main(){ Int d,a,b,c; cin>>d>>a>>b>>c; Int ans=min(solve1(a,b,c,d),solve2(a,b,c,d)); if(ans>=INF) ans=-1; cout<