a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
a_moji=str(a)
b_moji=str(b)
c_moji=str(c)
d_moji=str(d)
e_moji=str(e)

a1=int(a_moji[-1])
a1_moji=str(a1)
if a1==0:
    a1=10
a_kiriage=a+10-a1

b1=int(b_moji[-1])
b1_moji=str(b1)
if b1==0:
    b1=10
b_kiriage=b+10-b1

c1=int(c_moji[-1])
c1_moji=str(c1)
if c1==0:
    c1=10
c_kiriage=c+10-c1

d1=int(d_moji[-1])
d1_moji=str(d1)
if d1==0:
    d1=10
d_kiriage=d+10-d1

e1=int(e_moji[-1])
e1_moji=str(e1)
if e1==0:
    e1=10
e_kiriage=e+10-e1

k=10
if k>a1:
    k=a1
if k>b1:
    k=b1
if k>c1:
    k=c1
if k>d1:
    k=d1
if k>e1:
    k=e1
print(k)
goke=a_kiriage+b_kiriage+c_kiriage+d_kiriage+e_kiriage+k-10
print(goke)
