#include #include #include using namespace std; int BitCount(int number,int serch_bitnum){ int counter = 0; for(int i = 0; i < serch_bitnum; i++)if(number & (1 << i))counter++; return counter; } bool Found(vector meta,int data){ for(int i = 0; i < meta.size()-1; i++){if(meta[i] == data)return true;} return false; } int main(){ int N; vector onCell; int cellcount = 0; int cell = 1; int step = -1; cin >> N; while(1){ onCell.push_back(cell); cellcount++; if(cell == N){ cout << cellcount << endl; break; }else if(Found(onCell,cell)){ cout << -1 << endl; break; }else{ step = BitCount(cell,16); cell += cell+step <= N ? step : -step; } } return 0; }