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