def calc(stone) if (stone[0]!=0) return stone[0] + calc(stone.map{|e| e-stone[0]}) elsif (stone[1]==0 || stone[2]<=2) return 0 else k = stone[2] / 3 return calc([k,stone[1],stone[2]-k*2].sort!) end end r,g,b = gets.split.map(&:to_i) p calc([r,g,b].sort)