#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, A, B; cin >> N; vector>> E(N); for (int i=0; i> A >> B; A--; B--; E[A].push_back({B, i}); E[B].push_back({A, i}); } vector in(N, -1), low(N), tour, ancestor(N); vector double_edge(N); auto lowlink=[&](auto self, int from, int p)->void{ in[from] = tour.size(); low[from] = tour.size(); tour.push_back(from); ancestor[from] = p; for (auto [to, _] : E[from]){ if (to == p){ if (double_edge[from]) low[from] = min(low[from], in[to]); else double_edge[from]=1; continue; } if (in[to] != -1){ if (in[to] > in[from]) continue; low[from] = min(low[from], in[to]); //後退辺(子孫->祖先)を遡る } else self(self, to, from); } }; lowlink(lowlink, 0, -1); for (int i=N-1; i>=0; i--){ int x = tour[i]; for (auto [y, _] : E[x]){ if (y == ancestor[x]) continue; low[x] = min(low[x], low[y]); } } //二重辺連結成分分解(two edge connected component) vector> tecc_groups; vector _tecc, bridge, roots={0}; vector tecc_idx(N, -1); //頂点iの含まれる成分の番号 auto tecc=[&](auto self, int from)->void{ _tecc.push_back(from); tecc_idx[from] = tecc_groups.size(); for (auto [to, idx] : E[from]){ if (tecc_idx[to] != -1) continue; if (low[to] > in[from]){ bridge.push_back(idx); roots.push_back(to); } else self(self, to); } }; while(!roots.empty()){ int root = roots.back(); roots.pop_back(); tecc(tecc, root); tecc_groups.push_back(_tecc); _tecc.clear(); } vector ok(N, 1); for (auto x : bridge) ok[x] = 0; cout << N-bridge.size() << endl; for (int i=0; i