public class compiler
  Shared Sub Main()
    Dim n As Integer = CType(Console.ReadLine(), Integer)
    Dim input As String = Console.ReadLine()
    Dim p(0 To n - 1) As Integer 
    For i As Integer = 0 To n - 1
        p(i) = CType(input.split(" ")(i), Integer)
    Next
    
    Dim output As Integer = 0
    For i As Integer = 0 To n - 3
        If p(i) < p(i + 1) AndAlso p(i + 1) < p(i + 2) Then
            output += 1
        ElseIf p(i) > p(i + 1) AndAlso p(i + 1) > p(i + 2) Then
            output += 1
        End If
    Next

    Console.WriteLine(output.ToString())
  End Sub
end class
