n = gets.chomp.to_i m = gets.chomp.split.map(&:to_i) c = 0 (n - 2).times do | i | if n[i] != n[i+2] if n[i] > n[i+1] && n[i+1] < n[i+2] c += 1 elsif n[i] > n[i+1] && n[i+1] < n[i+2] c += 1 end end end puts k