a=int(input())
n=[]
m=[]
u=0
for i in range(a):
    m.append(0)
for i in range(a):
    a=int(input())
    n.append(a)
for i in range(1000000000000000):
    if n[i]>n[i+1]:
        l=m[i]
        m[i+1]= m[i]
        l=m[i+1]
        u+=1
print(u)
        
        
                
        
