inf=0x70000000 f='e>=0?e:0' read while read a b c do echo $[ a>c?t=a,a=c,c=t:0, a-=x=a==c, y=b>2?(e=c-(b-1),f)+(e=a-(b-2),f):inf, z=a>1?(e=b-(a-1),f):inf, x+=y=inf?-1:x ] done