import sys input = sys.stdin.readline N=int(input()) A=list(map(int,input().split())) ANS=0 for i in range(1,N): if A[i-1]>A[i]: ANS+=1 print(ANS)