use bigint; $a=<>+0; ++$j2 while 2**$j2<$a; ++$j3 while 3**$j3<$a; print 2*$j2<3*$j3?2*$j2:3*$j3;