#17853: Na: python 明明只差50%啊 請求大師指點


andy.uang@gmail.com (beelphegor)


while 1:
    try:
        def trace(x):
            if i != x:
                a=jojo[x]
                jojo[x]=-1
                return trace(a)
            else:
                global team
                team += 1
                return 0

        number=int(input())
        jojo=list(map(int,input().split()))
        global team
        team = 0
        for i in range(number):
            if jojo[i] != -1:
                trace(jojo[i])
        print(team)

    except EOFError:
        break