($A,$B,$S)=glob<>; if($S==1||abs($A-$S)<=abs($B-$S)){ print abs($A-$S)+$S }else{ print abs($B-$S)+($S-1)+abs($A-1)+1 }