macro_rules! scan { ($t:ty) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($t:ty;;) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::>() } }; ($t:ty; $n:expr) => { (0..$n).map(|_| scan!($t) ).collect::>() }; ($t:ty;;$n:expr) => { (0..$n).map(|_| scan!($t;;)).collect::>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| scan!($($t),*) ).collect::>() }; ($($t:ty),*) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; } fn main() { let n = scan!(usize); let mut i = 1; let mut ans = 0; while i < n { let mut num = 0; for j in 0..20 { if (i & 1 << j) != 0 { num += 1 } } i += num; ans += 1 } if i == n { println!("{}", ans); } else { println!("-1") } }