a,b,c,d,s,t;main(){scanf("%d%d%d%d",&d,&a,&b,&c);a>c?a^=c^=a^=c:a==c?s++,a=ab&c>b)&&c&&printf("%d",s)||!d&&puts("-1"))exit(0);t=(c-b)/d+1;t=a|t*d