### main

loop do
  a, b, c, d, e, f = gets.split.map(&:to_i)
  break if (a | b | c | d | e | f) == 0

  x = a + d
  y = b + e
  z = c + f

  min = [x, y, z].min
  max_c = 0

  for i in (0..2)
    break if min < i
    n4 = min - i
    c = (x - n4) / 3 + (y - n4) / 3 + (z - n4) / 3 + n4
    max_c = c if max_c < c
  end

  puts max_c
end