use std::io::{self, Read};
use std::string::String;
fn main() {
let mut stdin = io::stdin();
let mut str: String = String::new();
stdin.read_to_string(&mut str).unwrap();
let mut result: Vec<u32> = Vec::new();
let mut a: u32 = 0;
for line in str.split("\n") {
if line.is_empty() {
result.push(a);
a = 0;
} else {
a += line.parse::<u32>().unwrap();
}
}
if a > 0 { result.push(a); }
result.sort_by(|a, b| b.cmp(a));
// println!("{}", result[0]); // day 1
println!("{}", result[0] + result[1] + result[2]); // day 2
}