use std::io::*;
use std::str::FromStr;

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();

    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

use permutohedron::LexicalPermutation;

fn main() {
    let mut vec = [0; 5];
    for i in 0..5 {
        vec[i] = read::<usize>();
    }
    let mut permutations = Vec::new();
    loop {
        permutations.push(vec);
        if !vec.next_permutation() {
            break;
        }
    }

    let mut answer = std::usize::MAX;
    for x in permutations {
        let mut it = x.iter();
        let mut time: usize = 0;
        for i in 0..5 {
            while time % 10 != 0 {
                time += 1;
            }
            time += match it.next() {
                Some(&val) => val,
                None => 0,
            };
        }
        answer = std::cmp::min(answer, time);
    }
    println!("{}", answer);
}

