import numpy as np
n = int(input())
l = np.array([int(i) for i in input().split()])

orderd = np.array([i for i in range(1,n+1)],dtype = np.int64)

ans = 0
diff = (l == orderd)
diff = np.append(diff,False)
for i in range(n):
    if diff[i] == 1 and diff[i+1] == 0:
        ans += 1

print(ans)