import sys

dishes = map(int, sys.stdin.read().split())
ans = 0
d = 10
for dish in dishes:
    if dish % 10  < d:
        ans += 10 - d
        d = dish % 10
    else:
        ans += dish + 10 - dish % 10
print(ans)
