#include using namespace std; int main() { long n; long b = 1; int count = 0; // 標準入力から、空白や改行で区切られた整数と文字列を読み込む。 cin >> n; while(n > 0){ count++; if(1 < n / b ) b *= 2; if(n % 2 != 0)b--; n -= b; // cout << "i:" + to_string(i) << endl; // cout << "b:" + to_string(b) << endl; // cout << "count:" + to_string(count) << endl; } cout << count << endl; // 整数と文字列を空白で区切って、標準出力に書き出す。 return 0; }