a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst_1 = sorted([(a - 1) % 10, (b - 1) % 10, (c - 1) % 10, (d - 1) % 10, (e - 1) % 10])
print(lst_1[0])
print(((a+9)//10)*10 + ((b+9)//10)*10 + ((c+9)//10)*10 + ((d+9)//10)*10 + ((e+9)//10)*10 - (10 - (lst_1[0] + 1) if lst_1[0] != 9 else 0))