#include #include #include #include using namespace std; //namaega184 int f(int a){printf("%d\n",a);} int main(){ int d;int h[3];scanf("%d",&d);for(int i=0;i<3;i++)scanf("%d",&h[i]); int ans=1000000000,inf=1000000000; auto nextpos=[&](int now,int next){return (now-(next-1)+d-1)/d;}; int h1=h[0],h2=h[2],m,a=0; if(d>0){if(h1>=h[1]){m=nextpos(h1,h[1]);h1=max(0,h1-d*m),a+=m;} if(h[1]<=h2){m=nextpos(h2,h[1]);h2=max(0,h2-d*m);a+=m;} if(h1==h2){m=nextpos(h1,h2);h1=max(0,h1-d*m);a+=m;} } if(h1>=0&&h1!=h2)ans=min(ans,a); h1=h[1],h2=min(h[0],h[2]),a=0; if(d>0){ if(h[0]==h[2]){m=nextpos(h2,h[0]);h2=max(0,h2-d*m);a+=m;} if(h1>=h2){m=nextpos(h1,h2);h1=max(0,h1-d*m);a+=m;} } if(h1>=0&&h1!=h2)ans=min(ans,a); if(ans==inf)ans=-1; printf("%d\n",ans); return 0; }