using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace yukicoder { class yc { static void Main() { //8192 int N = int.Parse(Console.ReadLine()); int cout = 1; int place = 1; int move = 0; int before = 0; bool end = false; while (!end) { for (int i = 8192; 0 < i; i /= 2) { if ((place & i) != 0) { move++; } } if (place == N) { Console.WriteLine(cout); break; } if (place + move > N) { before = place; place -= move; cout++; } if (place + move <= N) { place += move; cout++; if (place == before) { Console.WriteLine(-1); break; } else { before = 0; } } move = 0; } } } }