const lines = require('fs') .readFileSync('/dev/stdin', 'utf-8') .trim().split('\n').values(); const N = BigInt(lines.next().value); const bonus = N * 2n; let normal = 0n; for (let n = N; n; n /= 2n) normal += n; console.log((bonus - normal).toString());