gets a = gets.split.map(&:to_i) count = 0 for i in 0..(a.size-3) do x, y, z = a[i], a[i+1], a[i+2] next if x == y || y == z || z == x next if x < y && y < z next if x > y && y > z count += 1 end puts count