a=eval('int(input()),'*5);print((min(~-i%10for i in a)-sum(-i//10*10for i in a)-9))
*a,=list(map(int,open(0)));print((min(~-i%10for i in a)-sum(-i//10*10for i in a)-9))
a = eval("int(input())," * 5)
print((min(~-i % 10 for i in a) - sum(-i // 10 * 10 for i in a) - 9))

(*a,) = list(map(int, open(0)))
print((min(~-i % 10 for i in a) - sum(-i // 10 * 10 for i in a) - 9))

-a = eval("int(input())," * 5) +(*a,) = list(map(int, open(0)))