a = (int(input()))
b = (int(input()))
c = (int(input()))
d = (int(input()))
e = (int(input()))

a1=[]
b1=[]
c1=[]
d1=[]
e1=[]
sum = a + b + c + d + e

while a>0:
    a1.append(a % 10)
    a //= 10

while b>0:
    b1.append(b % 10)
    b //= 10

while c>0:
    c1.append(c % 10)
    c //= 10

while d>0:
    d1.append(d % 10)
    d //= 10

while e>0:
    e1.append(e % 10)
    e //= 10

min = min(a1[0], b1[0], c1[0], d1[0], e1[0])
sum += (40 - a1[0] - b1[0] - c1[0] - d1[0] - e1[0] + min)

print(sum)
