using System; class Q0003 { public static void Main() { int n = int.Parse(Console.ReadLine()); bool[] is_stop = new bool[n]; int count = 1; int prev = -1; for(int i=1; ;) { if (i == n) { break; } int add = 0; for (int j=i; j>0; j/=2) { if(j%2 > 0) { add ++; } } if(i+add > n) { i -= add; if(is_stop[i - 1]) { count = -1; break; } } else { i += add; } prev = i; is_stop[i - 1] = true; count++; } Console.WriteLine(count); } }