#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 n1=terP.size();
	long long n2=zemP.size();
	if(pot>0){
		for(long long i=I;i<n1;i++){
			for(long long j=0;j<n2;j++){
				
				//
				

				
				if(terP[i]==(zemP[j])){
					//cout<<"GORE"<<terP[i]<<endl;
					
					zemP.push_back(terD[i]);
					if(i>zemP[j]){
						return 0;
					}
						//cout<<"prvi = "<<zemP[j-1]<<"  , drugi="<<zemP[j]<<" , i="<<i<<endl;
					pot--;
					return rastrkanostProv(terP,terD,zemP,pot,i+1)+1;
				}
				else if(terD[i]==(zemP[j])){
					//cout<<"DOLE"<<terD[i]<<endl;
						
					zemP.push_back(terP[i]);
					if(i>zemP[j]){
						return 0;
					}
						//cout<<"prvi = "<<zemP[j-1]<<"  , drugi="<<zemP[j]<<" , i="<<i<<endl;
					pot--;
					return rastrkanostProv(terP,terD,zemP,pot,i+1)+1;
				}
				else{
					continue;
				}	
				//
			}
			
		}
	}
	else{
		return 0;
	}
	return 0;
}


int main(){
	long long N,t1,t2,pot=-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]);
	long long rez=rastrkanostProv(terP,terD,zemP,pot,0);
	if((pot+1-rez)>rez){
		cout<<pot+1-rez;
	}
	else{
		cout<<rez;
	}
	return 1;
}