using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace YukiCoder_Cs { class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); int move = 0; int cnt = 1; int i = 1; List usedN = new List(); while (i < N) { move = Convert.ToString(i, 2).ToCharArray().Where(c => c == '1').Count(); if (usedN.Contains(i)) { cnt = -1; break; } usedN.Add(i); if (i + move > N) { i -= move; } else { i += move; } ++cnt; } Console.WriteLine($"{cnt}"); } } }