# t=int(input())
# for _ in range(t):
n=int(input())
arr=[int(x) for x in input().split()]
arr1=arr.copy()
arr1.sort()
count=0
for i in range(n):
    if arr[i] != arr1[i]:
        count+=1
print(count)
