class Yukicoder def initialize r, g, b = gets.chomp.split(' ').map(&:to_i) list = [r,g,b].sort sum = 0 zero_flag = false loop do a, b, c = list count = [1, [b - a, (c-b)/2].min].max count = 0 if list.max - list.min == 1 list[0] += count list[2] -= 2 * count create = [0, list.min].max if zero_flag if create.zero? break else zero_flag = false end else if create.zero? zero_flag = create.zero? else zero_flag = false end end sum += create list = list.map{|i| i - create}.sort end puts sum end end Yukicoder.new