using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace YukiCoder { class Program { static bool[] ng; static int rootN = -1; //------------------------------------------------------------------------------// static bool xxxxx(int ni, int nx) { if (ni < 1 ) return false; if (ni > nx) return false; if (ni == nx) { rootN = 1; return true; } if (ng[ni]) return false; ng[ni] = true; int n = 0; for (int nn = ni; nn > 0; nn >>= 1) { n += (nn & 1); } if (xxxxx(ni + n, nx)) { rootN++; return true; } if (xxxxx(ni - n, nx)) { rootN++; return true; } return false; } //------------------------------------------------------------------------------// static void Main(string[] args) { int nx = int.Parse(Console.ReadLine()); ng = new Boolean[nx]; xxxxx(1, nx); Console.WriteLine(rootN); Console.ReadLine(); } } }