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: u128 = xyh[0] as u128 * 1000; let y: u128 = xyh[1] as u128 * 1000; let h = xyh[2]; let mut cands: VecDeque<(u128, u128, usize, usize)> = VecDeque::new(); let mut used: HashSet<(u128, u128, usize, usize)> = HashSet::new(); let mut target: (u128, u128, usize, usize) = (x, y, h, 0); cands.push_back(target); used.insert(target); while cands.len() > 0 { target = cands.pop_front().unwrap(); if target.0 > target.2 as u128 { let next: (u128, u128, usize, usize) = (target.0 / 2, target.1, target.2 * 2, target.3+1); if !cands.contains(&next) { cands.push_back(next); used.insert(next); } } if target.1 > target.2 as u128 { let next: (u128, u128, usize, usize) = (target.0, target.1 / 2, target.2 * 2, target.3+1); if !cands.contains(&next) { cands.push_back(next); used.insert(next); } } } println!("{}", target.3); }