use std::collections::HashSet; use std::io::*; fn gcd(a: u64, b: u64) -> u64 { if b == 0 { return a; } gcd(b, a % b) } fn rec(x: u64, a: u64, b: u64, c: u64, st: &mut HashSet) { if x >= a * b * c || st.contains(&x) { return; } st.insert(x); rec(x + a, a, b, c, st); rec(x + b, a, b, c, st); rec(x + c, a, b, c, st); } 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 a: u64 = itr.next().unwrap().parse().unwrap(); let b: u64 = itr.next().unwrap().parse().unwrap(); let c: u64 = itr.next().unwrap().parse().unwrap(); if gcd(a, gcd(b, c)) != 1 { println!("INF"); } else { let mut st = HashSet::::new(); rec(0, a, b, c, &mut st); println!("{}", a * b * c - st.len() as u64); } }