use std::io::Read; 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 v1: usize = itr.next().unwrap().parse().unwrap(); let v2: usize = itr.next().unwrap().parse().unwrap(); let v3: usize = itr.next().unwrap().parse().unwrap(); let v4: usize = itr.next().unwrap().parse().unwrap(); let mut ans: usize = 99; for i in 1..31 { for j in i + 1..31 { for k in j + 1..31 { let mut dp: Vec = vec![99; 99]; dp[i] = 1; dp[j] = 1; dp[k] = 1; for l in 1..31 { dp[l + i] = std::cmp::min(dp[l + i], dp[l] + 1); } for l in 1..31 { dp[l + j] = std::cmp::min(dp[l + j], dp[l] + 1); } for l in 1..31 { dp[l + k] = std::cmp::min(dp[l + k], dp[l] + 1); } ans = std::cmp::min(ans, dp[v1] + dp[v2] + dp[v3] + dp[v4]); } } } println!("{}", ans); }