function main() n=parse(BigInt,readline()) x=n*2 y=big(0) while n > 0 y += n n>>=1 end println(x-y) end