use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let mut x = 1; let mut ans = 0; while x * 2 <= n { ans += 1; x <<= 1; } if x != n { ans += x - (n + 1) / 2 + 1; ans += n & 1; } println!("{}", ans); }