time_arr = []
 
5.times {|_| time_arr << STDIN.gets.to_i }
 
def evaluate(sol, time_arr)
  sol = sol.dup
  t = 0
  while sol.size > 1
    t += time_arr[sol.shift]
    t = t.ceil(-1)
  end
  t += time_arr[sol.shift]
  t
end
 
min = 9999999
 
ARR = [0, 1, 2, 3, 4]
ARR.permutation {|sol|
  d = evaluate(sol, time_arr)
  min = d if min > d 
}
 
STDOUT.puts min