#include <iostream>
using namespace std;
int main(){
int n; cin >> n;
int status = 0, res = 0;
int pre = -1;
for(int i = 0; i < n; i ++ ){
int tmp; cin >> tmp;
if(pre == -1) pre = tmp;
else if(pre > tmp){
if(status){
if(status > 0) res ++ , status = -1;
}else status = -1;
pre = tmp;
}else if(pre < tmp){
if(status){
if(status < 0) res ++ , status = 1;
}else status = 1;
pre = tmp;
}
}
cout << res << endl;
return 0;
}