#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; #ifndef LOCAL #define debug(x) ; #else #define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; template ostream &operator<<(ostream &out, const pair &p) { out << "{" << p.first << ", " << p.second << "}"; return out; } template ostream &operator<<(ostream &out, const vector &v) { out << '{'; for (const T &item : v) out << item << ", "; out << "\b\b}"; return out; } #endif #define mod 1000000007 //1e9+7(prime number) #define INF 1000000000 //1e9 #define LLINF 2000000000000000000LL //2e18 #define SIZE 200010 vector tree[SIZE]; pair dfs(int now, int prev = -1){ pair res = {0, now}; for (int to : tree[now]) { if (to != prev) { res = max(dfs(to, now), res); } } res.first += 1; return res; } int main(){ int n; cin >> n; for(int i=0;i> a >> b; a--; b--; tree[a].push_back(b); tree[b].push_back(a); } auto p = dfs(0); p = dfs(p.second); cout << n - p.first << endl; return 0; }