import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int count = 0; int[][] figure = new int[n][2]; figure[0][0] = sc.nextInt(); figure[0][1] = sc.nextInt(); for(int i=1;i figure[i-j][0]) { if(figure[i][0] > figure[i-j][1] && figure[i][1] < figure[i-j][1]) { count++; } } else if(figure[i][0] < figure[i-j][1] && figure[i][1] > figure[i-j][1]) { if(figure[i][0] > figure[i-j][0] && figure[i][1] < figure[i-j][0]) { count++; } } } } System.out.println(count); } }