#include #include #include using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,n,0) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 1e8 typedef long long ll; int main() { int d, h1, h2, h3; cin >> d >> h1 >> h2 >> h3; if (h1 > h3) swap(h1,h3); if (h1 == 0 && h2 == 0 || h3 == 0) cout << -1 << endl; else if (h1 == h2 && h2 == h3) { if (h1 > d) cout << 3 << endl; else cout << -1 << endl; } else if (h1 == h3) { if (h1 < h2) cout << 1 << endl; else if (h1 < d) cout << -1 << endl; else if (h1 - d == h2) { if (h1 < 2*d) cout << -1 << endl; else cout << 2 << endl; } else cout << 1 << endl; } else if (h1 == h2) { if (d > 0 && h1 >= d) cout << 1 << endl; else cout << -1 << endl; } else if (h2 == h3) { if (h1 == h3 - d) { if (h3 > 2*d) cout << 2 << endl; else cout << -1 << endl; } else if (d > 0 && h3 >= d) cout << 1 << endl; else cout << -1 << endl; } else if ((h2 < h1 || h2 > h3)) cout << 0 << endl; else if (d == 0) cout << -1 << endl; else { int x, y; x = (h2-h1)/d+1; if (h1 != max(0,h2 - x*d)) x = (h2-h1)/d+1; else if (h1 != max(0,h2 - (x+1)*d)) x++; else x = 1e9; y = (h3-h2)/d+1; if (h2 != max(0,h3 - y*d) && h1 != max(0,h3 - y*d)) y = (h3-h2)/d+1; else if (h1 != max(0,h3 - (y+1)*d)) y++; else if (h1 != max(0,h3 - (y+2)*d)) y += 2; else y = 1e9; if (min(x,y) == 1e9) cout << -1 << endl; else cout << min(x,y) << endl; } return 0; }