You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly xbacteria in the box at some moment.
What is the minimum number of bacteria you need to put into the box across those days?
Input
The only line containing one integer x (1 ≤ x ≤ 109).
Output
The only line containing one integer: the answer.
Examples
input
5
output
2
input
8
output
1
solution:
找一下n的二进制中1的个数
#include<cstdio>
using namespace std;
int main()
{
int n,ans=0;
scanf("%d", &n);
while (n)
{
if (n & 1)ans++;
n >>= 1;
}
printf("%d\n", ans);
return 0;
}