n = gets.to_i x = n y = n * 2 while n / 2 != 0 n = n / 2 x += n end puts y - x