def Tmin(n) count = 0 while n & 1 == 0 count += 1 n /= 2 end (count == 0 ? 0 : count - 1) + n end n = gets.to_i print Tmin(n) print ' ' puts n - 1