def solve if N == 1 0 else a = Math.log2(N).ceil b = 2**a - N a + b end end N = gets.to_i puts solve