#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main() { ll d; cin >> d; ll a, b, c; cin >> a >> b >> c; if ((a < b && b > c) || (a > b && b < c)) { puts("0"); }else if (b == 0 || d == 0) { puts("-1"); }else { ll ans = 0; if (b <= a) { ans += (a-b)/d+1; } if (b <= c) { ans += (c-b)/d+1; } ans = min(ans, (b-min(a, c))/d+1); std::cout << ans << std::endl; } }