Module Module1

    Sub Main()
        Dim n As Integer = CInt(Console.ReadLine())
        Dim str As String() = Console.ReadLine().Split(" ")
        Dim str2 As List(Of String) = New List(Of String)()
        Dim i As Integer
        Dim c As Integer = 0
        For j = 0 To UBound(str)
            If (str2.Contains(str(j)) = False) Then
                If (str(CInt(str(j)) - 1) = j + 1) Then
                    c = c + 1
                    str2.Add(j + 1)
                    str2.Add(str(CInt(str(j)) - 1))
                End If
            End If
        Next
        Console.WriteLine(c)
        'If c2 > c1 Then Console.WriteLine(c1.ToString()) Else Console.WriteLine(c2.ToString())


        Dim yyyyy As Integer = 0
    End Sub

End Module




