while n = gets.split.map(&:to_i)
  break if n.all?{ |v| v == 0 }
  m = Array.new
  3.times { |i| m << n[i]+n[i+3] }
  ret = 0
  3.times do |i|
    break if m.any?{ |v| v - i < 0 }
    ret = [ret, m.reduce(0){ |sum, v| sum += (v - i) / 3 } + i].max
  end
  p ret
end