import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String str = sc.nextLine();
    List<String> strList = Arrays.asList(str.split(" "));
    List<List<Integer>> list = new ArrayList<List<Integer>>();
    for(int i = 0; i < n - 2; i++){
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    }
    int count = 0;
    for(int i = 0; i < list.size(); i++){
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    }
    System.out.print(count);
  }
  public static boolean test(List<Integer> list, int secondElem){
  	boolean ret = false;
    Collections.sort(list);
    if(list.get(1) == secondElem){
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    }
    return ret;
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String str = sc.nextLine();
    List<String> strList = Arrays.asList(str.split(" "));
    List<List<Integer>> list = new ArrayList<List<Integer>>();
    for(int i = 0; i < n - 2; i++){
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    }
    int count = 0;
    for(int i = 0; i < list.size(); i++){
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    }
    System.out.print(count);
  }
  public static boolean test(List<Integer> list, int secondElem){
  	boolean ret = false;
    Collections.sort(list);
    if(list.get(1) == secondElem){
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    }
    return ret;
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String str = sc.nextLine();
    List<String> strList = Arrays.asList(str.split(" "));
    List<List<Integer>> list = new ArrayList<List<Integer>>();
    for(int i = 0; i < n - 2; i++){
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    }
    int count = 0;
    for(int i = 0; i < list.size(); i++){
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    }
    System.out.print(count);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String str = sc.nextLine();
    List<String> strList = Arrays.asList(str.split(" "));
    List<List<Integer>> list = new ArrayList<List<Integer>>();
    for(int i = 0; i < n - 2; i++){
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    }
    int count = 0;
    for(int i = 0; i < list.size(); i++){
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    }
    System.out.print(count);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc List<String> strList = Arrays.asList(str.split(" ")); strList Arrays.asList(str.split(" ")) Arrays.asList Arrays str.split(" ") str.split str " " List<List<Integer>> list = new ArrayList<List<Integer>>(); list new ArrayList<List<Integer>>() for(int i = 0; i < n - 2; i++){
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    } int i = 0; int i = 0; i 0 i < n - 2 i n - 2 n 2 i++ i++ i {
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    } {
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    } List<Integer> tmp = new ArrayList<Integer>(); tmp new ArrayList<Integer>() tmp.add(Integer.parseInt(strList.get(i))) tmp.add tmp Integer.parseInt(strList.get(i)) Integer.parseInt Integer strList.get(i) strList.get strList i tmp.add(Integer.parseInt(strList.get(i+1))) tmp.add tmp Integer.parseInt(strList.get(i+1)) Integer.parseInt Integer strList.get(i+1) strList.get strList i+1 i 1 tmp.add(Integer.parseInt(strList.get(i+2))) tmp.add tmp Integer.parseInt(strList.get(i+2)) Integer.parseInt Integer strList.get(i+2) strList.get strList i+2 i 2 list.add(tmp) list.add list tmp int count = 0; count 0 for(int i = 0; i < list.size(); i++){
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    } int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list i++ i++ i {
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    } {
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    } List<Integer> tmp = list.get(i); tmp list.get(i) list.get list i if(test(tmp, tmp.get(1)) == true){
        count++;
      } test(tmp, tmp.get(1)) == true test(tmp, tmp.get(1)) test tmp tmp.get(1) tmp.get tmp 1 true {
        count++;
      } count++ count System.out.print(count) System.out.print System.out System System.out count String[] args args public static boolean test(List<Integer> list, int secondElem){
  	boolean ret = false;
    Collections.sort(list);
    if(list.get(1) == secondElem){
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    }
    return ret;
  } test {
  	boolean ret = false;
    Collections.sort(list);
    if(list.get(1) == secondElem){
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    }
    return ret;
  } boolean ret = false; ret false Collections.sort(list) Collections.sort Collections list if(list.get(1) == secondElem){
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    } list.get(1) == secondElem list.get(1) list.get list 1 secondElem {
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    } if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      } list.get(1) != list.get(0) && list.get(1) != list.get(2) list.get(1) != list.get(0) list.get(1) list.get list 1 list.get(0) list.get list 0 list.get(1) != list.get(2) list.get(1) list.get list 1 list.get(2) list.get list 2 {
	    ret = true;
      } ret = true ret true return ret; ret List<Integer> list list int secondElem secondElem public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String str = sc.nextLine();
    List<String> strList = Arrays.asList(str.split(" "));
    List<List<Integer>> list = new ArrayList<List<Integer>>();
    for(int i = 0; i < n - 2; i++){
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    }
    int count = 0;
    for(int i = 0; i < list.size(); i++){
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    }
    System.out.print(count);
  }
  public static boolean test(List<Integer> list, int secondElem){
  	boolean ret = false;
    Collections.sort(list);
    if(list.get(1) == secondElem){
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    }
    return ret;
  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String str = sc.nextLine();
    List<String> strList = Arrays.asList(str.split(" "));
    List<List<Integer>> list = new ArrayList<List<Integer>>();
    for(int i = 0; i < n - 2; i++){
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    }
    int count = 0;
    for(int i = 0; i < list.size(); i++){
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    }
    System.out.print(count);
  }
  public static boolean test(List<Integer> list, int secondElem){
  	boolean ret = false;
    Collections.sort(list);
    if(list.get(1) == secondElem){
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    }
    return ret;
  }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String str = sc.nextLine();
    List<String> strList = Arrays.asList(str.split(" "));
    List<List<Integer>> list = new ArrayList<List<Integer>>();
    for(int i = 0; i < n - 2; i++){
      	List<Integer> tmp = new ArrayList<Integer>();
      	tmp.add(Integer.parseInt(strList.get(i)));
      	tmp.add(Integer.parseInt(strList.get(i+1)));
      	tmp.add(Integer.parseInt(strList.get(i+2)));
      	list.add(tmp);
    }
    int count = 0;
    for(int i = 0; i < list.size(); i++){
      List<Integer> tmp = list.get(i);
      if(test(tmp, tmp.get(1)) == true){
        count++;
      }
    }
    System.out.print(count);
  }
  public static boolean test(List<Integer> list, int secondElem){
  	boolean ret = false;
    Collections.sort(list);
    if(list.get(1) == secondElem){
      if(list.get(1) != list.get(0) && list.get(1) != list.get(2)){
	    ret = true;
      }
    }
    return ret;
  }
}