Program ABC123B

integer a(5),b(5),x,y,s,p

read(*,*) a

do i=1,5
 b(i)=mod(a(i),10)
end do

do i=1,5
 do j=1,5
  if (b(i)<b(j)) then
   x=b(i)
   b(i)=b(j)
   b(j)=x
   y=a(i)
   a(i)=a(j)
   a(j)=y
  end if
 end do
end do

s=0
p=1
do while (b(p)==0)
 s=s+a(p)
 p=p+1
end do

s=s+a(p)

do i=p+1,5
 s=s+(a(i)/10+1)*10
end do

write(*,*) s

stop
end