#include using namespace std; using i64 = int64_t; using vi = vector; using vvi = vector; int main() { int d; int a, b, c; cin >> d >> a >> b >> c; if (a < b && b > c) { cout << 0 << endl; return 0; } if (a > b && b < c) { cout << 0 << endl; return 0; } if (d == 0 || b == 0) { cout << -1 << endl; return 0; } int ans = -1; int k = min(a, c); if (k != 0) { int diff = b - (k - 1); ans = (diff + d - 1) / d; } k = max(a, c); if (k != 0) { int diff = k - (b - 1); if (ans == -1) { ans = (diff + d - 1) / d; } else { ans = min(ans, (diff + d - 1) / d); } } cout << ans << endl; }