#include <iostream>
#include <vector>
#include <climits>
#include <map>
using namespace std;
long long DP[2][200005];
vector<long long> adj[200005];
void DFS(long long u,long long p)
{
DP[0][u] = 0;
DP[1][u] = LLONG_MIN;
for(int i=0;i<adj[u].size();i++)
{
long long v = adj[u][i];
if(v == p)
{
continue;
}
DFS(v,u);
DP[0][u] += max(DP[0][v],DP[1][v]);
DP[1][u] = max(DP[1][u],min(DP[0][v]-DP[1][v],(long long)0));
}
DP[1][u]+=DP[0][u];
DP[1][u]++;
}
int main() {
int n;
cin>>n;
for(int i=0;i<n-1;i++)
{
int a,b;
cin>>a>>b;
adj[a-1].push_back(b-1);
adj[b-1].push_back(a-1);
}
DFS(0,-1);
cout<<max(DP[0][0],DP[1][0])<<endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8Y2xpbWl0cz4KI2luY2x1ZGUgPG1hcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmxvbmcgbG9uZyBEUFsyXVsyMDAwMDVdOwp2ZWN0b3I8bG9uZyBsb25nPiBhZGpbMjAwMDA1XTsKCnZvaWQgREZTKGxvbmcgbG9uZyB1LGxvbmcgbG9uZyBwKQp7CglEUFswXVt1XSA9IDA7CglEUFsxXVt1XSA9IExMT05HX01JTjsKCQoJZm9yKGludCBpPTA7aTxhZGpbdV0uc2l6ZSgpO2krKykKCXsKCQlsb25nIGxvbmcgdiA9IGFkalt1XVtpXTsKCQlpZih2ID09IHApCgkJewoJCQljb250aW51ZTsKCQl9CgkJCgkJREZTKHYsdSk7CgkJCgkJRFBbMF1bdV0gKz0gbWF4KERQWzBdW3ZdLERQWzFdW3ZdKTsKCQlEUFsxXVt1XSA9IG1heChEUFsxXVt1XSxtaW4oRFBbMF1bdl0tRFBbMV1bdl0sKGxvbmcgbG9uZykwKSk7CgkJCgl9CglEUFsxXVt1XSs9RFBbMF1bdV07CglEUFsxXVt1XSsrOwp9CgoKaW50IG1haW4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