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: u64 = itr.next().unwrap().parse().unwrap(); let mut a = Vec::new(); for i in 0..60 { if n >> i & 1 == 1 { a.push(i); } } let target = 1u64 << a.len() - 1; let mut ans = 0; for i in 0..60 { if target >> i & 1 == 1 { ans += 1 << a[i]; } } println!("{}", ans); }