from operator import itemgetter
import math
a=[i for i in input()]
b=[i for i in input()]
c=[i for i in input()]
d=[i for i in input()]
e=[i for i in input()]
nums = []
nums.append(a)
nums.append(b)
nums.append(c)
nums.append(d)
nums.append(e)
nums.sort(key=itemgetter(-1),reverse = True)
last = 0
for num in nums:
    if num[-1]!="0":
        last= num[-1]
ans = 0
for num in nums:
    ans+=math.ceil(int("".join(num))/10)*10
print(ans-(10-int(last)))