#include using namespace std; using ll = long long; vector C,D; void dfs(int n,vector> &G){ C[n]=1; for(int v:G[n]){ D[v]=D[n]+1; dfs(v,G); C[n]+=C[v]; } } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin>>N; vector> G(N); vector R(N,1); for(int i=0;i>a>>b; a--;b--; R[b]=0; G[a].push_back(b); } int r=0; for(int i=0;i