using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Numerics; namespace yukikoda { class Program { static void Main(string[] args) { BigInteger n = long.Parse(Console.ReadLine()); BigInteger n2 = n; BigInteger a = 0; while (n != 0) { a += n; n /= 2; } Console.WriteLine((2 * n2) - a); } } }