program aa;
var
ar:array[1..1000] of integer;
l,a,i,j,k:longint;
f:text;
begin
assign(f,'officer.in');
reset(f);
readln(f,a);
for i:=1 to a do
readln(f,ar[i]);
for i:=1 to a do
if ar[ar[i]]=i then begin
l:=ar[i];
i:=ar[ar[i]];
ar[ar[i]]:=l;
inc(k);
end;
for j:=1 to a do
for i:=1 to a do
if ar[i]<>i then
begin
l:=ar[ar[i]];
ar[ar[i]]:=ar[i];
ar[i]:=l;
inc(k);
end;
assign(f,'officer.out') ;
rewrite(f);
write(f,k+1);
close(f);
end.