import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int count = 0;
Cat cat = new Cat(new Scanner(System.in));
boolean hasUp = false;
while (!cat.onEnd()) {
if (!hasUp) {
if (cat.rightMoveDirection == RightMoveDirection.up) hasUp = true;
} else if (cat.rightMoveDirection == RightMoveDirection.down) {
count++;
hasUp = false;
}
cat.move();
}
System.out.println(count);
}
}
class Cat {
final Scanner explorer;
int step = 0;
final int roadLen;
Integer point1, point2;
RightMoveDirection rightMoveDirection = RightMoveDirection.flat;
private ReplaceableCode replaceableCode;
Cat(Scanner scanner) {
explorer = scanner;
roadLen = scanner.nextInt();
replaceableCode = () -> {
point1 = explorer.nextInt();
replaceableCode = () -> {
point2 = explorer.nextInt();
upDirection();
replaceableCode = () -> {
point1 = point2;
point2 = explorer.nextInt();
upDirection();
};
};
};
}
boolean onEnd() {
return step == roadLen;
}
void move() {
if (onEnd()) return;
replaceableCode.content();
step++;
}
private void upDirection() {
if (point1 < point2) rightMoveDirection = RightMoveDirection.up;
else if (point1 > point2) rightMoveDirection = RightMoveDirection.down;
else rightMoveDirection = RightMoveDirection.flat;
}
}
enum RightMoveDirection {
up, flat, down
}
@FunctionalInterface
interface ReplaceableCode {
void content();
}