using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yukicoder { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); Console.WriteLine("{0}", Count(N)); Console.ReadLine(); } static int Count(int n) { int c = 0; int have = 1; int P = 0; ; while(have < n) { have--; P = 1; while (have + P < n) { P = P * 2; c++; } have += P; } return c; } } }