fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn cmp_2(a:i64, b:i64) -> std::cmp::Ordering {
    let (xi, yi) = (a % 10, b % 10);

    if xi == yi {
        std::cmp::Ordering::Equal
    } else if xi == 0 && yi != 0 {
        std::cmp::Ordering::Greater
    } else if xi != 0 && yi == 0 {
        std::cmp::Ordering::Less
    } else if xi > yi {
        std::cmp::Ordering::Greater
    } else {
        std::cmp::Ordering::Less
    }
}

fn main() {
    let mut r:Vec<i64> = Vec::new();
    r.push(get_input().parse().unwrap());
    r.push(get_input().parse().unwrap());
    r.push(get_input().parse().unwrap());
    r.push(get_input().parse().unwrap());
    r.push(get_input().parse().unwrap());

    r.sort_unstable_by(|&a, &b| cmp_2(b, a));

    let mut ans = 0;
    for i in r {
        let a = ans % 10;
        ans += if a == 0 { 0 } else { 10 - a };
        ans += i;
    }
    println!("{}", ans);
}
