{$APPTYPE CONSOLE} var i,j,n,s:integer;f:text; a,b:array [1..1000] of integer; begin assign(f,'Liars.dat');reset(f); readln(f,n); for i:=1 to n do read(f,a[i]); close(f); s:=0; for i:=1 to n do b[i]:=0; for i:=1 to n do for j:=1 to n do if a[j]=i then inc(b[i]); for i:=1 to n do if b[i]=i then inc(s); if s=1 then s:=0; assign(f,'Liars.sol');rewrite(f); write(f,s);close(f); end.