ll@N,@(P--)[N]; setS; rep(i,N){ int s=P[i]; if(s==-1)continue; int t=P[s]; if(t!=-1)S.insert(t); } wt((int)S.size());