
fun main(args: Array<String>?): Unit {
    while(true){
        val (math, greedy, geometry, dp, graph, other) = readLine()!!.trim().split(' ').map(String::toInt).let{ if (it.all { it == 0 }) return else it}
        val mathGame = math + dp
        val algo = greedy + graph
        val write = geometry + other
        println((0 .. listOf(2, mathGame, algo, write).min()!!).map{i ->
            i + (mathGame - i) / 3 + (algo - i) / 3 + (write - i) / 3
        }.max()!!)
    }
}
operator fun <T> List<T>.component6(): T {return this[5]}
