#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n;
int dp[5555][5555][2];
vector<int> g[5555];
int leaves[5555];
void dfs(int v, int p) {
  if (g[v].size() == 1) {
    dp[v][0][1] = 0;
    dp[v][1][0] = 0;
    dp[v][1][1] = inf;
    dp[v][0][0] = inf;
  } else {
    int d[2][5555][2], mxcnt = 0;
    for (int i = 0; i <= n; ++i) d[0][i][0] = d[0][i][1] = inf;
    d[0][0][0] = d[0][0][1] = 0;
    int id = 0;
    for (int j = 0; j < g[v].size(); ++j) {
      int to = g[v][j];
      if (to == p) continue;
      dfs(to, v);
      for (int j = 0; j <= mxcnt + leaves[to]; ++j) {
        d[id ^ 1][j][0] = d[id ^ 1][j][1] = inf;
      }
      for (int k = leaves[to]; k >= 0; --k) {
        for (int l = mxcnt; l >= 0; --l) {
          d[id ^ 1][l + k][0] =
              min(d[id ^ 1][l + k][0], d[id][l][0] + dp[to][k][0]);
          d[id ^ 1][l + k][0] =
              min(d[id ^ 1][l + k][0], d[id][l][0] + dp[to][k][1] + 1);
          d[id ^ 1][l + k][1] =
              min(d[id ^ 1][l + k][1], d[id][l][1] + dp[to][k][1]);
          d[id ^ 1][l + k][1] =
              min(d[id ^ 1][l + k][1], d[id][l][1] + dp[to][k][0] + 1);
        }
      }
      mxcnt += leaves[to];
      id ^= 1;
    }
    for (int i = 0; i <= mxcnt; ++i) {
      dp[v][i][0] = d[id][i][0];
      dp[v][i][1] = d[id][i][1];
    }
  }
}
void dfs0(int v, int p) {
  if (g[v].size() == 1) {
    leaves[v] = 1;
  } else {
    leaves[v] = 0;
    for (int i = 0; i < g[v].size(); ++i) {
      int to = g[v][i];
      if (to == p) continue;
      dfs0(to, v);
      leaves[v] += leaves[to];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int v;
  cin >> n;
  if (n == 2) {
    cout << 1;
    return 0;
  }
  int leafs = 0;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 0; i < n; ++i) {
    if (g[i].size() > 1) {
      v = i;
      break;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (g[i].size() == 1) leafs++;
  }
  dfs0(v, -1);
  dfs(v, -1);
  leafs >>= 1;
  cout << min(dp[v][leafs][0], dp[v][leafs][1]);
  return 0;
}
