let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map(fun x -> int x)
let char2String(value) = List.ofSeq value |> List.toArray |> System.String

[for i in [1..5] -> readInt()]
|> List.sortBy (fun x -> (x - 1) % 10)
|> fun x ->  
    match x with
    | h :: t -> h + List.sumBy (fun x -> x + if x % 10 = 0 then 0 else 10 - x % 10) t 
    | _ -> 0
|> printfn "%d"