n = int(input())
p = list(map(int, input().split()))
cnt = 0
pp = [1 if p[i-1] == i else 0 for i in range(1, n+1)]
for i in range(n):
    if pp[i]==1:
        if i+1!=n and pp[i+1]==1:
            cnt-=1
        cnt+=1
print(cnt)