n = int(input()) a = list(map(int, input().split())) i = 0 ans = 0 while i < n: j = i + 1 while j < n and a[j-1] > a[j]: j += 1 ans += (j - i + 1) // 2 i = j print(ans)