($a,$b,$c)=glob<>; print+($g=grep+($d=$a%$_-$b%$_)*($e=$b%$_-$c%$_)<0&&$d&&$e&&$c%$_-$a%$_,2..2e3)<1e3?$g:INF