fn gcd(a: usize, b: usize) -> usize { if b == 0 { return a; } gcd(b, a%b) } fn lcm(a: usize, b: usize) -> usize { a / gcd(a, b) * b } fn main() { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let a = temp[0]; let b = temp[1]; let c = temp[2]; let d = temp[3]; let e = temp[4]; let lcmval = lcm(a+b, c+d); let mut cnt = 0usize; for i in 0..lcmval { if i % (a+b) < a && i % (c+d) < c { cnt += 1; } } let mut result = cnt * (e / lcmval); for i in e/lcmval*lcmval..e { if i % (a+b) < a && i % (c+d) < c { result += 1; } } println!("{}", result); }