#include <bits/stdc++.h>
const char en = '\n';
using namespace std;
vector<vector<long long> > V(6000);
vector<long long> sum(6000, 0);
vector<vector<vector<long long> > > D(6000, vector<vector<long long> >(2));
int n;
void merge(vector<long long> &a, vector<long long> &b, vector<long long> &c) {
  vector<long long> tmp(n + 47, 1000000000000000047);
  if (a.size() == 0) {
    for (int j = 0; j < b.size(); j++) {
      tmp[j] = min(tmp[j], b[j]);
    }
    for (int j = 0; j < c.size(); j++) {
      tmp[j] = min(tmp[j], c[j] + 1);
    }
  } else {
    for (int i = 0; i < a.size(); i++)
      for (int j = 0; j < b.size(); j++)
        tmp[i + j] = min(tmp[i + j], a[i] + b[j]);
    for (int i = 0; i < a.size(); i++)
      for (int j = 0; j < c.size(); j++)
        tmp[i + j] = min(tmp[i + j], a[i] + c[j] + 1);
  }
  int pos = n + 42;
  while (tmp[pos] == 1000000000000000047) pos--;
  for (int i = 0; i <= pos; i++) {
    if (a.size() > i)
      a[i] = tmp[i];
    else
      a.push_back(tmp[i]);
  }
}
void dfs(int c, int f) {
  if (V[c].size() == 1) {
    D[c][1].push_back(1000000000000000047);
    D[c][0].push_back(0);
    sum[c] = 1;
    D[c][1].push_back(0);
    return;
  }
  for (int i = 0; i < V[c].size(); i++) {
    if (V[c][i] != f) {
      dfs(V[c][i], c);
      sum[c] += sum[V[c][i]];
      merge(D[c][1], D[V[c][i]][1], D[V[c][i]][0]);
      merge(D[c][0], D[V[c][i]][0], D[V[c][i]][1]);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  int v = -1;
  for (int i = 1; i <= n; i++) {
    if (V[i].size() > 1) v = i;
  }
  if (v == -1) {
    cout << 1 << en;
    return 0;
  }
  dfs(v, -1);
  cout << D[v][1][sum[v] / 2] << en;
}
