import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;
		int up = 0;
		int down = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		}

		System.out.println(count);

		sc.close();
	}
}; import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;
		int up = 0;
		int down = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		}

		System.out.println(count);

		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;
		int up = 0;
		int down = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		}

		System.out.println(count);

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;
		int up = 0;
		int down = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		}

		System.out.println(count);

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int count = 0; count 0 int up = 0; up 0 int down = 0; down 0 Integer Array[] = new Integer[N]; Array new Integer[N] N for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			Array[i] = sc.nextInt();
		} {
			Array[i] = sc.nextInt();
		} Array[i] = sc.nextInt() Array[i] Array i sc.nextInt() sc.nextInt sc for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		} int i = 0; int i = 0; i 0 i < N-1 i N-1 N 1 i++ i++ i {
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		} {
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		} if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			} Array[i]<Array[i+1] Array[i] Array i Array[i+1] Array i+1 i 1 {
				up++;
				down=0;
			} up++ up down=0 down 0 {
				down++;
				up=0;
			} down++ down up=0 up 0 if(up==2||down==2){
				count++;
			} up==2||down==2 up==2 up 2 down==2 down 2 {
				count++;
			} count++ count up=Math.min(up,1) up Math.min(up,1) Math.min Math up 1 down=Math.min(down,1) down Math.min(down,1) Math.min Math down 1 System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;
		int up = 0;
		int down = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		}

		System.out.println(count);

		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;
		int up = 0;
		int down = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		}

		System.out.println(count);

		sc.close();
	}
} Main
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;
		int up = 0;
		int down = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		for(int i = 0; i < N-1; i++){
			if(Array[i]<Array[i+1]){
				up++;
				down=0;
			}else{
				down++;
				up=0;
			}
			if(up==2||down==2){
				count++;
			}
			up=Math.min(up,1);
			down=Math.min(down,1);
		}

		System.out.println(count);

		sc.close();
	}
};
