class Calc0091 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @r, @g, @b = args.shift.map(&:to_i) end def run min, max = 0, (@r + @g + @b) / 3 + 1 bs(min, max) end def bs(min, max) cur = (min + max) / 2 if cur == min cur else check(cur) ? bs(cur, max) : bs(min, cur) end end def check(k) lack = [@r, @g, @b].map { |s| k - s }.select(&:positive?).inject(:+) || 0 excess = [@r, @g, @b].map { |s| (s - k) / 2 }.select(&:positive?).inject(:+) || 0 excess >= lack end end puts Calc0091.new(STDIN.readlines).run if __FILE__ == $0