n=int(input())
p=list(map(int,input().split()))
a=[i for i in range(1,n+1)]
c=[0]*n

for i in range(n):
    if a[i]==p[i]:
        c[i]=1
#print(c)
ans=0
for i in range(n-1):
    if c[i]==c[i+1]==1:
        ans+=1
for i in range(n-2):
    if c[i]==c[i+2]==0 and c[i+1]==1:
        ans+=1
if c[0]==1 and c[1]==0:
    ans+=1
if c[-1]==1 and c[-2]==0:
    ans+=1


print(ans)