import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int be = sc.nextInt();
		int ans = 0;
		boolean check1 = false, check2 = false;
		for(int i = 1; i < N; i++){
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int be = sc.nextInt();
		int ans = 0;
		boolean check1 = false, check2 = false;
		for(int i = 1; i < N; i++){
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int be = sc.nextInt();
		int ans = 0;
		boolean check1 = false, check2 = false;
		for(int i = 1; i < N; i++){
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int be = sc.nextInt();
		int ans = 0;
		boolean check1 = false, check2 = false;
		for(int i = 1; i < N; i++){
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int be = sc.nextInt(); be sc.nextInt() sc.nextInt sc int ans = 0; ans 0 boolean check1 = false check1 false check2 = false; check2 false for(int i = 1; i < N; i++){
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		} {
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		} int ch = sc.nextInt(); ch sc.nextInt() sc.nextInt sc if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			} be < ch be ch {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			} if(check1 == true) ans++; check1 == true check1 true ans++ ans check1 = true check1 true check2 = false check2 false if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			} be > ch be ch {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			} if(check2 == true) ans++; check2 == true check2 true ans++ ans check1 = false check1 false check2 = true check2 true {
				check1 = false;
				check2 = false;
			} check1 = false check1 false check2 = false check2 false be  = ch be ch System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int be = sc.nextInt();
		int ans = 0;
		boolean check1 = false, check2 = false;
		for(int i = 1; i < N; i++){
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int be = sc.nextInt();
		int ans = 0;
		boolean check1 = false, check2 = false;
		for(int i = 1; i < N; i++){
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int be = sc.nextInt();
		int ans = 0;
		boolean check1 = false, check2 = false;
		for(int i = 1; i < N; i++){
			int ch = sc.nextInt();
			if(be < ch) {
				if(check1 == true) ans++;
				check1 = true;
				check2 = false;
			}else if(be > ch) {
				if(check2 == true) ans++;
				check1 = false;
				check2 = true;
			}else {
				check1 = false;
				check2 = false;
			}
			be  = ch;
		}
		System.out.println(ans);
	}
}