#!/usr/bin/env python3
#ABC123 B

LI = [int(input()) for _ in range(5)]
LI2 = [LI[i] % 10 for i in range(5)]

x = [(LI[i],LI2[i]) for i in range(5)]
#print(x)

ans = 0
x = sorted(x, key = lambda x:x[1],reverse = True)
for i in range(5):
    if x[i][1] == 0:
        t = x[i]
        x.remove(t)
        x.insert(0,t)
#print(x)

for i in range(4):
    ans += x[i][0] + (10 - x[i][1])
ans += x[4][0]
print(ans)
