gets;p gets.split.map(&:hex).each_cons(3).count{|x,y,z|x!=z&&(x-y)*(y-z)<0}