#27071: help python NA 55%


mcg25035@gmail.com (南瓜切)


input()

row_input = input()

input_ = row_input.split(" ")

removed_quantity = 0

for i in input_:

    input_[input_.index(i)] = int(i)

data = []

while not removed_quantity == len(input_):

    next_people = 0

    while input_[next_people] == "not_exist":

        next_people+=1

    current_group = []

    while not next_people in current_group:

        current_group.append(next_people)

        next_people = input_[next_people]

    for i in current_group:

        input_[input_.index(i)] = "not_exist"

        removed_quantity += 1

    data.append(current_group)

print(len(data))