vector<int>reste; int cont=0; int Atem=A; while(A>a&&A/2>a){ reste.push_back(A%2); A/=2; cont++; } cont+=A-a; for(auto val:reste) if(val==1) cont++; cout<<cont;