#include<bits/stdc++.h>

using namespace std;

long long rastrkanostProv(vector<long long> terP,vector<long long> terD,vector<long long> zemP,long long pot,long long I){ //ako ovo radi ja sam ajnstajn...
	long long N=terP.size();
	long long zN=zemP.size();
	if(pot>=0){
		for(long long i=I;i<N;i++){
			if(terP[i]==zemP[zN-1]){
				zemP.push_back(terD[i]);
				pot--;
				return (1+rastrkanostProv(terP,terD,zemP,pot,i+1));
			}
			else if(terD[i]==zemP[zN-1]){
				zemP.push_back(terP[i]);
				pot--;
				return (1+rastrkanostProv(terP,terD,zemP,pot,i+1));
			}
		}
	}
	else{
		return 0;
	}
}


int main(){
	long long N,t1,t2,ras=1,pot,t=1;
	vector<long long> terP;
	vector<long long> terD;
	vector<long long> zemP;
	cin>>N;
	for(long long i=0;i<(N-1);i++){
		cin>>t1>>t2;
		terP.push_back(t1);
		terD.push_back(t2);
	}
	if(N%2==0){//koliko poteza ima prvi igrac
		pot=N/2;
	}
	else{
		pot=N/2+1;
	}
	zemP.push_back(terP[0]);
	zemP.push_back(terD[0]);
	cout<<rastrkanostProv(terP,terD,zemP,pot,0);
	return 1;
}