from math import ceil
n=int(input())
p=list(map(int,input().split()))
m=[]
l=[0]*n
for i in range(n):
    if p[i]==i+1:
        l[i]=1
# print(l)
t=0
for i in range(n-1):
    if i==n-2:
        if l[i]==1:
            t+=1
        m.append(t)
        break

    if l[i]==1:
        t+=1
        if l[i+1]==1:
            continue
        m.append(t)
        t=0
# print(m)
ans=0
for mm in m:
    ans+=ceil(mm/2)
print(ans)
