gets
while gets
    m = 0
    can0 = $_.split.map(&:to_i)
    (0 .. can0.min).each do |x|
        can1 = can0.map {|k| k - x}
        (0 .. can1[0]/3).each do |y|
            can2 = can1.dup
            can2[0] -= 3 * y
            z = [can2[0]/2, can2[1]].min
            m = x + y + z if x + y + z > m
        end
    end
    p m
end