#include #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define FFOR(i,a,b) for(int i=(a);i<=(b);i++) #define REP(i,b) FOR(i,0,b) #define RREP(i,b) FFOR(i,1,b) #define PB push_back #define F first #define S second #define BE(c) c.begin(),c.end() using namespace std; typedef long long LL; typedef int ut; typedef long double ld; typedef pair pr; typedef vector Vpr; typedef vector VI; typedef pair ppr; typedef vector Vppr; typedef priority_queue > PQ; typedef priority_queue > PprQ; const int SIZE=5+3*1e+5; const LL INF=1LL<<60; const ld eps=1e-6; const LL p=7+1e+9; LL nums[SIZE]; LL solve(){ LL d,H[3]; cin >> d; REP(i,3) cin >> H[i]; if(H[0]>H[2]) swap(H[0],H[2]); LL ans=INF; if(H[0]==H[1] || H[0]==H[2] || H[1]==H[2]) if(d==0) return -1; if(H[0]&& H[1] || H[1]&&H[2] || H[2]&&H[0]);else return -1; if(H[0]==0 && H[2]==0) return -1; if(H[1]max(H[2],H[0])) { if(H[0]!=H[2]) return 0; if(H[1]>H[2]) return 1; if(H[2]<=d) return -1; if(H[2]-d<=H[1]) return 2; return 1; } if(d==0) return -1; if(H[0]==H[1] && H[1]==H[2]){ if(H[1]<=d) return -1; return 3; } if(H[0]&& H[2])ans=min(ans,(H[1]-min(H[0],H[2]))/d+1); if(H[1]<=d && H[0]==0){ if(H[2]%d==0 || H[2]%d>=H[1]) return -1; } if(H[1]-H[0]<=d && (H[2]-H[0])%d==0){ if(H[0]==0) return -1; ans=min(ans,max(0LL,H[2]-H[1]+d)/d+max(0LL,H[0]-H[1]+d)/d+1); } ans=min(ans,max(0LL,H[2]-H[1]+d)/d+max(0LL,H[0]-H[1]+d)/d); if(ans==INF) return -1; else return ans; } int main(){ string s; cout << solve() << endl; return 0; }