Module Module1

    Sub Main()
        Dim N As Integer = Val(Console.ReadLine())
        Dim t As String() = Split(Console.ReadLine(), " ")
        Dim a(N - 1) As Integer
        For i As Integer = 0 To N - 1
            a(i) = Val(t(i)) - 1
        Next
        Dim count As Integer = 0
        For i As Integer = 0 To N - 1
            If a(a(i)) = i Then count += 1
        Next
        Console.WriteLine(count / 2)
        Stop
    End Sub

End Module
