#include <stdio.h>
int main(void){
    int n,big=2,small=2,ans=0;
    scanf("%d",&n);
    int p[n];
    scanf("%d",&p[0]);
    for(int i=1; i<n; i++){
        scanf("%d",&p[i]);
        if(p[i-1]<p[i]){
            big=1;
            if(small==0)
                ans++;
            small=0;
        }
        else{
            small=1;
            if(big==0)
                ans++;
            big=0;
        }
    }
    printf("%d",ans);
}
