def isKadomatsu a,b,c if a == b || b == c || c == a return false end if [a,b,c].min == b || [a,b,c].max == b return true else return false end end def isZoukaKadomatsu a 5.times{|i| if isKadomatsu(a[i], a[i + 1], a[i + 2]) && a[i] < a[i + 2] next else return false end } return true end d = gets.split.map(&:to_i).sort d.permutation(7).to_a.each{|a| if isZoukaKadomatsu(a) puts "YES" exit end } puts "NO"