#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10, INF = 1e9;
int dp[N][N][2], cur[N][2], cnt[N], n;
vector<int> g[N];
void smin(int &a, int b) {
  if (a > b) a = b;
}
void dfs(int v, int par) {
  dp[v][0][0] = 0;
  for (int i = 0; i <= n; i++) cur[i][0] = cur[i][1] = INF;
  if (g[v].size() == 1) {
    cnt[v] = 1;
    dp[v][1][1] = 0;
    return;
  }
  dp[v][0][1] = 0;
  for (auto u : g[v]) {
    if (u == par) continue;
    dfs(u, v);
    for (int i = 0; i <= cnt[v]; i++)
      for (int j = 0; j <= cnt[u]; j++)
        for (int k = 0; k < 4; k++) {
          int f = k / 2, s = k & 1;
          smin(cur[i + j][f], dp[u][j][s] + dp[v][i][f] + (f ^ s));
        }
    cnt[v] += cnt[u];
    for (int i = 0; i <= cnt[v]; i++) {
      dp[v][i][0] = cur[i][0];
      dp[v][i][1] = cur[i][1];
      cur[i][0] = cur[i][1] = INF;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  if (n == 2) {
    cout << "1\n";
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int rt;
  for (int i = 0; i < n; i++) {
    if (g[i].size() > 1) rt = i;
    for (int j = 0; j <= n; j++) dp[i][j][0] = dp[i][j][1] = INF;
  }
  dfs(rt, -1);
  cout << min(dp[rt][cnt[rt] / 2][1], dp[rt][cnt[rt] / 2][0]) << "\n";
}
