#include #define ll long long #define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++) #define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++) #define ALL(obj) (obj).begin(), (obj).end() #define RALL(obj) (obj).rbegin(), (obj).rend() #define fi first #define se second #define pb push_back #define debug(x) cerr << #x << ": " << (x) << endl #define int long long using namespace std; using II = pair; using VI = vector; using VVI = vector; using VVVI = vector; template inline T in() { T x; cin >> x; return x; } template inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template ostream& operator<<(ostream &s, const vector& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; } template ostream& operator<<(ostream &s, const vector>& dd) { for (vector d: dd) s << d << endl; return s; } struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast; const int MOD = 1e9 + 7; int d; // h2をでかくする int solve1(int h1, int h2, int h3) { int a1 = max(0ll, (h1 - h2 + d) / d); int a3 = max(0ll, (h3 - h2 + d) / d); h1 = max(0ll, h1 - d * a1); h3 = max(0ll, h3 - d * a3); if (h1 == h3 && h1 == 0) return 1e10; return a1 + a3 + (h1 == h3); } // h2を小さくする int solve2(int h1, int h2, int h3) { int ans = 0; if (h1 == h3) { h1 = max(0ll, h1 - d); ans++; } if (h1 == 0 || h3 == 0) return 1e10; return ans + max(0ll, (h2 - min(h1, h3) + d) / d); } signed main() { int h1, h2, h3; cin >> d >> h1 >> h2 >> h3; int ans = min(solve1(h1, h2, h3), solve2(h1, h2, h3)); cout << (ans == 1e10 ? -1 : ans) << endl; }