#include <bits/stdc++.h>
using namespace std;
const int ms = 5050;
int dp[ms][ms], sz[ms], temp[ms];
vector<int> adj[ms];
int n;
void dfs(int u, int p = -1) {
  sz[u] = 0;
  dp[u][0] = 0;
  for (auto v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
    for (int i = 0; i <= sz[u]; ++i) {
      temp[i] = dp[u][i];
    }
    memset(dp[u], 0x3f, sizeof dp[u]);
    for (int i = 0; i <= sz[u]; ++i) {
      for (int j = 0; j <= sz[v]; ++j) {
        dp[u][i + j] =
            min(dp[u][i + j], temp[i] + min(dp[v][j], 1 + dp[v][sz[v] - j]));
      }
    }
    sz[u] += sz[v];
  }
  if (sz[u] == 0) {
    dp[u][0] = 0;
    dp[u][1] = 1;
    sz[u]++;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  if (n == 2) {
    cout << "1\n";
    return 0;
  }
  int save;
  for (int i = 0; i < n; ++i) {
    if (adj[i].size() > 1) {
      save = i;
      dfs(save);
      break;
    }
  }
  cout << dp[save][sz[save] / 2] << '\n';
  return 0;
}
