#include using namespace std; using ll = long long; int main(){ ll d; vector a(3); cin >> d >> a[0] >> a[1] >> a[2]; auto f1 = [&](ll v1, ll v2, ll v3){ ll mn = min(v1, v3); if(mn == 0)return 1ll << 60; ll c = max(0ll, v2 - (mn - 1)), ans = (c + d - 1) / d; if(v1 == v3){ if(v1 <= d)return 1ll << 60; ans++; } return ans; }; auto f2 = [&](ll v1, ll v2, ll v3){ ll ans = 0; ll c = (max(0ll, v1 - (v2 - 1)) + d - 1) / d; ans += c, v1 -= d * c; c = (max(0ll, v3 - (v2 - 1)) + d - 1) / d; ans += c, v3 -= d * c; if(min(v1, v3) < 0)return 1ll << 60; if(v1 == v3){ if(v1 == 0)return 1ll << 60; } return ans; }; ll ans = min(f1(a[0], a[1], a[2]), f2(a[0], a[1], a[2])); if(ans >> 60)ans = -1; cout << ans << '\n'; }