#include "bits/stdc++.h" #define Rep(i,n) for(int i=0;i> a(n,vector(m,0)); using namespace std; typedef long long ll; typedef pair P; template inline bool chmax(T& a, T b) {if(a inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;} int n; vector a; vector b; vector> e; vector visited; int dfs(int c,int dis=0){ int m=0; REP(i,e[c].size()){ if(!visited[e[c][i]]){ visited[e[c][i]]=1; chmax(m,dfs(e[c][i],dis+1)); //return dfs(e[c],dis+1); } } return m; } int main(){ cin >> n; a.resize(n-1); b.resize(n-1); e.resize(n); REP(i,n-1){ cin >> a[i] >> b[i]; a[i]--; b[i]--; e[a[i]].push_back(b[i]); e[b[i]].push_back(a[i]); } visited.resize(n,0); queue q; q.push(0); visited[0]=1; int maxv=0; while(!q.empty()){ int v = q.front();q.pop(); REP(i,e[v].size()){ if(!visited[e[v][i]]){ visited[e[v][i]]=visited[v]+1; maxv=e[v][i]; q.push(e[v][i]); } } } //int d = dfs(0); //visited.resize(n,0); REP(i,n){ visited[i]=0; } q.push(maxv); visited[maxv]=1; int m=0; while(!q.empty()){ int v = q.front();q.pop(); REP(i,e[v].size()){ if(!visited[e[v][i]]){ visited[e[v][i]]=visited[v]+1; chmax(m,visited[e[v][i]]); q.push(e[v][i]); } } } put(n-m); return 0; }