# -*- coding: utf-8 -*-


from sys import stdin


############################################
def Combination(n,r):
    tmp_list = []
    for cmb in cmb_list:
        tmp_list.append(cmb)
    for first_data in data_list:
        for second_data in tmp_list:
            split_tmp_list = second_data.split(",")
            obj_list = []
            for split_data in split_tmp_list:
                obj_list.append(split_data)
            if obj_list.count(first_data) == 0:
                obj_list.append(first_data)
                join_data = ",".join(sorted(obj_list))
                if join_data not in cmb_list:
                    cmb_list.append(join_data)
    if r > 2:
        Combination(n,r-1)
    return(cmb_list)

def cal_time(cmb):
    time = 0
    for i in cmb:
        time += i
#        print(time)
        if time%10!=0 and i!=cmb[4]:
            time += 10 - time % 10
#        print(time)
    return time
    
# read data for n sequences.
input=[]
for _ in range(5):
    input.append(int(stdin.readline().split()[0]))

cmb_list = []

import itertools
cmb = list(itertools.permutations(input))


prev = 10e6
for x in cmb:
    t = cal_time(x)
#    print(x)
    prev = min(t, prev)
print(prev)