puts gets. to_i. to_s(2). each_char. inject(0) {|x,y| y == "1" ? x + 1 : x }