N = int(input())
p = list(map(int,input().split()))
ans,cnt,tmp = 0,0,0
for i in range(N):
    if i+1!=p[i]:
        continue
    cnt += 1
    if cnt%2==0:
        ans += (i+1)-tmp
    tmp = i+1
if cnt%2==1:
    ans += 1
print(ans)
