<?php

for($i=0;$i<5;$i++){
    $array[$i] = trim(fgets(STDIN));
}

$time = 0;
$min = 10;
$x = 0;
$y = 0;

for($i=0;$i<5;$i++){
    $x = $array[$i] % 10;
    if($x < $min && $x != 0){
        $min = $x;
        $num = $i;
    }
}

$tmp = $array[4];
$array[4] = $array[$num];
$array[$num] = $tmp;


for($i=0;$i<4;$i++){
    $time += $array[$i];
    while($time % 10 != 0){
        $time++;
    }
}

$time += $array[4];


echo $time;

?>