import math
n,l =  input() , [ q-p for p,q in enumerate([ i for i,j in enumerate( map( int , input().split())) if i+1 == j ] ) ]
print( sum( [ math.ceil(l.count(j)/2) for i,j in enumerate(l) if i==0  or l[i]!=l[i-1]]))