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

ans = min(a%10, b%10, c%10, d%10, e%10) + (a+(10-a%10)) + (b+(10-b%10))+(c+(10-c%10))+(d+(10-d%10))+(e+(10-e%10)) -10

print(ans)