#include int*cells; int max; void game(int run_count,int id){ int count = (id & 0x5555) + ((id >> 1) & 0x5555); count = (count & 0x3333) + ((count >> 2) & 0x3333); count = (count & 0x0f0f) + ((count >> 4) & 0x0f0f); count = (count & 0x00ff) + ((count >> 8) & 0x00ff); cells[id]=run_count; if(id+count<=max&&cells[id+count]>run_count){ cells[id+count]=run_count; game(run_count+1,id+count); } if(id-count>0&&cells[id-count]>run_count){ cells[id-count]=run_count; game(run_count+1,id-count); } } int main(){ std::cin>>max; cells=new int[max+1]; for(int i=1;i<=max;i++){ cells[i]=max+100; } game(1,1); if(cells[max]==max+100){ std::cout<<-1<