use std::collections::{HashSet, VecDeque}; fn main() { let mut xyh: String = String::new(); std::io::stdin().read_line(&mut xyh).ok(); let xyh: Vec = xyh.trim().split_whitespace().map(|i| i.parse().unwrap()).collect(); let x: usize = xyh[0] as usize * 1000; let y: usize = xyh[1] as usize * 1000; let h = xyh[2]; let mut cands: VecDeque<(usize, usize, usize)> = VecDeque::new(); let mut used: HashSet<(usize, usize, usize)> = HashSet::new(); let mut target: (usize, usize, usize) = (0, 0, h); cands.push_back(target); used.insert(target); while cands.len() > 0 { target = cands.pop_front().unwrap(); if x > target.2 * 2usize.pow(target.0 as u32) { let next: (usize, usize, usize) = (target.0 + 1, target.1, target.2 * 2); if !cands.contains(&next) { cands.push_back(next); used.insert(next); } } if y > target.2 * 2usize.pow(target.1 as u32) { let next: (usize, usize, usize) = (target.0, target.1 + 1, target.2 * 2); if !cands.contains(&next) { cands.push_back(next); used.insert(next); } } } println!("{}", target.0 + target.1); }