use std::io::{ self, prelude::* }; fn clp2(mut x: u64) -> u64 { assert!(x > 0); x -= 1; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; x |= x >> 32; x + 1 } fn ntz(mut x: u64) -> u64 { if x == 0 { return 64; } let mut n = 1; if (x & 0x00000000FFFFFFFF) == 0 { n += 32; x >>= 32; } if (x & 0x000000000000FFFF) == 0 { n += 16; x >>= 16; } if (x & 0x00000000000000FF) == 0 { n += 8; x >>= 8; } if (x & 0x000000000000000F) == 0 { n += 4; x >>= 4; } if (x & 0x0000000000000003) == 0 { n += 2; x >>= 2; } n - (x & 1) } fn f(mut n: u64) -> (u64, u64) { let mut a = 0; while n % 2 == 0 { n /= 2; a += 1; } (a, n) } fn main() { let mut s = String::new(); io::stdin().read_to_string(&mut s).unwrap(); let mut tokens = s.split_whitespace(); let n: u64 = tokens.next().unwrap().parse().unwrap(); let (a, b) = f(n); let c = clp2(b); let ans = ntz(c) + c-b + a; println!("{}", ans); }