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