Module Module1

    Sub Main()
        Dim n As Integer = CInt(Console.ReadLine())
        Dim str As String() = Console.ReadLine().Split(" ")
        Dim str2 As String() = New String()
        Dim c As Integer = 0
        For j = 0 To UBound(str)
            If (Not ct(str2, str(j))) Then
                If (str(CInt(str(j)) - 1) = j + 1) Then
                    c = c + 1
                    add(j + 1, str2)
                    add(str(CInt(str(j)) - 1), str2)
                End If
            End If
        Next
        Console.WriteLine(c)
    End Sub

    Function ct(abc As String(), cmp As String) As Boolean
        For i = 0 To UBound(abc)
            If (abc(i) = cmp) Then Return True
        Next
        Return False
    End Function

    Function add(val As String, abc As String()) As String()
        Dim ns As String = ""
        For i As Integer = 0 To UBound(abc)
            ns &= abc(i) & " "
        Next
        ns &= val
        Return Split(ns, " ")
    End Function

End Module