#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef PRINTERS
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
vi adj[100005],D[100005];
int dist[100005],par[100005];
pii cnt[100005];
bool mark[100005];
void dfs(int u,int p){
  dist[u]=dist[p]+1;
  par[u]=p;
  for(auto x:adj[u])
    if(x!=p)
      dfs(x,u);
}
void solve(){
  int n,i,u,v,c1,c2,res=0;
  cin>>n;
  for(i=0;i<n-1;i++){
    cin>>u>>v;
    u++,v++;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  dfs(1,0);
  u=0;
  for(i=1;i<=n;i++)
    if(dist[i]>dist[u])
      u=i;
  dfs(u,0);
  v=0;
  for(i=1;i<=n;i++)
    if(dist[i]>dist[v])
      v=i;
  if(dist[v]&1){
    c1=v;
    for(i=0;i<dist[v]/2;i++)
      c1=par[c1];
    c2=c1;
  }
  else{
    c1=v;
    for(i=0;i<dist[v]/2-1;i++)
      c1=par[c1];
    c2=par[c1];
  }
  dist[c1]=dist[c2]=0;
  dfs(c1,c2);
  dfs(c2,c1);
  for(i=1;i<=n;i++)
    D[dist[i]].pb(i);
  for(i=n;i>0;i--){
    set<int> p;
    for(auto x:D[i]){
      p.insert(par[x]);
      if(mark[x])
        cnt[par[x]].F++;
      else
        cnt[par[x]].S++;
    }
    for(auto x:p){
      if(cnt[x].F)
        mark[x]=1;
      if(cnt[x].S>1){
        res+=cnt[x].S-1;
        mark[x]=1;
      }
      cnt[x].F=cnt[x].S=0;
    }
  }
  if(c1!=c2 and !mark[c1] and !mark[c2]){
    res++;
  }
  cout<<res;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t=1;
//  cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 15872