program main
  implicit none
  integer :: i, idx, num, first=10, time(5), total = 0

  do i = 1, 5
    read *, time(i)
    num = mod(time(i), 10)
    if ((num > 0) .and. (num < first)) then
      first = num
      idx = i
    end if
  end do

  do i = 1, 5
    if (i == idx) cycle
    total = total + time(i) 
    if (mod(time(i), 10) /= 0) then
      total = total - mod(time(i), 10) + 10
    end if
  end do

  if (first < 10) then
    total = total + time(idx)
  end if

  print '(i0)', total

end program