#include #include #include #include #include using namespace std; int main(){ int N; cin >> N; vector> G(N); int start = -1; for(int i=0;i> a >> b; a--, b--; G[a].push_back(b); G[b].push_back(a); } queue one; for(int i=0;i road; int ans = 0; while(!one.empty()){ int start = one.front(); one.pop(); if(road.count(start)) continue; queue> Q; vector visited(N,false); vector back(N,-1); Q.push({start,0}); visited[start] = true; int end = start; int dia = 0; while(!Q.empty()){ pair p = Q.front(); Q.pop(); bool ok = true; for(int to : G[p.first]){ if(road.count(to)) ok = false; } if(!ok) break; for(int to : G[p.first]){ if(visited[to]) continue; visited[to] = true; if(dia <= p.second+1){ back[to] = p.first; end = to; dia = p.second+1; } Q.push({to,p.second+1}); } } while(end != start){ road.insert(end); end = back[end]; } road.insert(start); ans++; } ans--; cout << ans << endl; }