方法一
 import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            System.out.println(Integer.bitCount(n));
        }
    }
} 方法二
 import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            int count = 0;
            while(n != 0){
                if((n&1) == 1){
                    count++;
                }
                n >>>= 1;
            }
            System.out.println(count);
        }
    }
}