#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
using namespace std;
const int N = 5003;
vector<int> adj[N];
int n, nl;
int dp[N][N][2];
int dpa[N][2];
int s[N];
void dfs1(int u, int pr) {
  s[u] = 0;
  bool isl = 1;
  for (int v : adj[u])
    if (v != pr) {
      isl = 0;
      dfs1(v, u);
      s[u] += s[v];
    }
  s[u] += isl;
}
void init() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dp[i][j][0] = dp[i][j][1] = INF;
}
void dfs(int u, int pr) {
  int lfx = 0;
  for (int v : adj[u])
    if (v != pr) dfs(v, u), lfx++;
  if (!lfx) {
    dp[u][0][0] = dp[u][1][1] = 0;
    return;
  }
  dp[u][0][0] = 0;
  dp[u][0][1] = lfx;
  for (int v : adj[u])
    if (v != pr) {
      for (int w = 0; w <= s[u]; ++w) {
        dpa[w][0] = dp[u][w][0];
        dpa[w][1] = dp[u][w][1];
      }
      for (int j = s[v]; j >= 0; j--)
        for (int w = s[u] - j; w >= 0; --w) {
          dpa[w + j][0] = min(dpa[w + j][0], dp[v][j][0] + dp[u][w][0]);
          dpa[w + j][0] = min(dpa[w + j][0], dp[v][j][1] + 1 + dp[u][w][0]);
          dpa[w + j][1] = min(dpa[w + j][1], dp[v][j][1] + dp[u][w][1] - 1);
          dpa[w + j][1] = min(dpa[w + j][1], dp[v][j][0] + dp[u][w][1]);
        }
      for (int w = 0; w <= s[u]; ++w) {
        dp[u][w][0] = min(dp[u][w][0], dpa[w][0]);
        dp[u][w][1] = min(dp[u][w][1], dpa[w][1]);
      }
    }
}
int main() {
  ios::sync_with_stdio(false);
  int u, v;
  cin >> n;
  for (int(i) = (1); (i) < (n); ++(i)) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ro = 0;
  for (int(i) = (0); (i) < (n); ++(i)) {
    nl += adj[i].size() == 1;
    ro = adj[i].size() > 1 ? i : ro;
  }
  init();
  dfs1(ro, -1);
  dfs(ro, -1);
  cout << min(dp[ro][nl / 2][1], dp[ro][nl / 2][0]) << '\n';
  return 0;
}
