loop do
    a = gets.split.map(&:to_i)
    break if a.all? {|x| x == 0}
    x, y, z = a[0] + a[3], a[1] + a[4], a[2] + a[5]
    n = 0
    while x > 3
        n += 1
        x -= 3
    end
    while y > 3
        n += 1
        y -= 3
    end
    while z > 3
        n += 1
        z -= 3
    end
    r = [x, y, z].sort
    if r[0] == 3
        n += 3
    elsif r[0] == 2
        n += 2
    elsif r[0] == 1 && r[1] <= 2
        n += 1
    else
        n += 1 if r[1] == 3
        n += 1 if r[2] == 3
    end
    puts n
end
