n=int(input())
P=list(map(int, input().split()))
s=[]
for i in range(1,n+1):
    if i==P[i-1]:
        s.append('x')
    else:
        s.append('o')
#print(s)
m=0
for i in range(n-1):
    a=s[i]
    b=s[i+1]
    if a+b=='xx' or a+b=='ox' or a+b=='xo':
        s[i]='o'
        s[i+1]='o'
        m+=1    

print(m)