_,*a=`dd`.split.map &:to_i;p a.each_cons(3).filter{_1!=_3 and (_1-_2)*(_2-_3)<0}.count