using System; using System.Numerics; public static class P { public static void Main() { string ns = Console.ReadLine(); BigInteger n = 0; foreach (var c in ns) n = n * 10 + c - '0'; BigInteger res = 0; while (n > 0) { res += n; n >>= 1; } Console.WriteLine(n * 2 - res); } }