fn main() { let mut mn = String::new(); std::io::stdin().read_line(&mut mn).ok(); let mut mn = mn.trim().split_whitespace(); let mut m: u32 = mn.next().unwrap().parse().unwrap(); let mut n: u32 = mn.next().unwrap().parse().unwrap(); let mut ans = 0u32; while m != 0 && n != 0 { if m < n { std::mem::swap(&mut m, &mut n); ans += 1; } ans += m / n; m %= n; } println!("{}", ans - 1); }