f,c,s;main(a,b){if(scanf("%d",&c)-1)exit(!printf("%d",s));++f>3&(a-b)*(c-b)>0&&a-c&&s++;main(b,c);}