while true
    arr = gets.chomp.split.map(&:to_i)
    break if arr == [0, 0, 0, 0, 0, 0]

    arr2, arr3 = [], []
    3.times{|i|
        q, r = (arr[i] + arr[i + 3]).divmod(3)
        arr2 << q
        arr3 << r
    }
    sum = arr2.inject(:+) + arr3.min
    sum += 1 if arr3.sort == [0, 2, 2] && arr2[arr3.index(0)] > 0
    puts sum
end

