gets;p gets.split.map(&:to_i).each_cons(3).count{|e|e.minmax&[e[1]]!=[]&&e|[]==e}