# Enter your code here. Read input from STDIN. Print output to STDOUT a = gets.strip.split(' ').map(&:to_i) b = gets.strip.split(' ').map(&:to_i) c = gets.strip.split(' ').map(&:to_i) diff1 = 15 - a.inject(0) {|e,n| e+n } diff2 = 15 - b.inject(0) {|e,n| e+n } diff3 = 15 - c.inject(0) {|e,n| e+n } diff4 = 15 - a[0] - b[0] - c[0] diff5 = 15 - a[1] - b[1] - c[1] diff6 = 15 - a[2] - b[2] - c[2] puts [diff1,diff2,diff3,diff4,diff5,diff6].reject {|n| n==0}.map(&:abs).min