l = [str(input()) for i in range(5)]
dct = {}
total = 0
a = []
b = []
c = []
for n in l:
    dct[n] = n[-1]
for k, v in sorted(dct.items(), key=lambda x: x[1], reverse=True):
    if int(v) == 0:
        b.append([int(k), int(v)])
    else:
        a.append([int(k), int(v)])
c.append(a[-1]) 
a = a[:-1]
for i in a:
    total += i[0] + 10 - i[1]
for i in b:
    total += i[0]
total += c[0][0]
print(total)