#include<iostream>
#include <queue>
#define ll long long int
using namespace std;
int main(){
ll n,r,c;
cin>>n;
ll g[n][n],visited[n],lastnode,sum=0,a,b;
for(ll i=0;i<n;i++)
for(ll j=0;j<n;j++)
if(i==j)
g[i][j]=0;
else
g[i][j]=-1;
for(ll i=0;i<n-1;i++){
cin>>a>>b;
g[a-1][b-1]=1;
g[b-1][a-1]=1;
}
for(ll i=0;i<n;i++)
visited[i]=0;
queue<ll> q;
q.push(0);
visited[0]=1;
while(!q.empty()){
r=q.front();
q.pop();
for(ll i=0;i<n;i++)
if(g[r][i]==1 && !visited[i]){
q.push(i);
visited[i]=1;
}
}
lastnode=r;
for(ll i=0;i<n;i++)
visited[i]=0;
visited[r]=1;
q.push(r);
while(!q.empty()){
lastnode=q.front();
q.pop();
c=0;
for(ll i=0;i<n;i++)
if(g[lastnode][i]==1 && !visited[i]){
if(c==0){
sum++;
c=1;
}
visited[i]=1;
q.push(i);
}
}
cout<<sum;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlIDxxdWV1ZT4KI2RlZmluZSBsbCBsb25nIGxvbmcgaW50IAp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpewoJbGwgbixyLGM7CgljaW4+Pm47CglsbCBnW25dW25dLHZpc2l0ZWRbbl0sbGFzdG5vZGUsc3VtPTAsYSxiOwoJZm9yKGxsIGk9MDtpPG47aSsrKQoJCWZvcihsbCBqPTA7ajxuO2orKykKCQkJaWYoaT09aikKCQkJCWdbaV1bal09MDsKCQkJZWxzZQkKCQkJCWdbaV1bal09LTE7Cglmb3IobGwgaT0wO2k8bi0xO2krKyl7CgkJY2luPj5hPj5iOwoJCWdbYS0xXVtiLTFdPTE7CgkJZ1tiLTFdW2EtMV09MTsKCX0KCWZvcihsbCBpPTA7aTxuO2krKykKCQl2aXNpdGVkW2ldPTA7CglxdWV1ZTxsbD4gcTsKCXEucHVzaCgwKTsKCXZpc2l0ZWRbMF09MTsKCQl3aGlsZ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