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 ] ) ]

dict = {}
for i in l:
  if i in dict:
    dict[i] += 1
  else:
    dict[i] = 1


print( sum( [ math.ceil(i/2) for i in dict ] ) )