#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
const int M = 1e6 + 5;
const int Mod = 998244353;
int n, dp[N][N][2];
vector<int> G[N];
int Try(int u, int p) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 2; j++) dp[u][i][j] = N;
  if (G[u].size() == 1) {
    dp[u][0][0] = dp[u][1][1] = 0;
    return 1;
  }
  int sz = 0;
  dp[u][0][0] = dp[u][0][1] = 0;
  for (auto v : G[u]) {
    if (v == p) continue;
    int szv = Try(v, u);
    sz += szv;
    for (int i = sz; i >= 0; i--) {
      int TempDP[2] = {N, N};
      for (int j = 0; j <= szv; j++)
        for (int b1 = 0; b1 < 2; b1++)
          for (int b2 = 0; b2 < 2; b2++) {
            int k = i - j;
            if (k < 0) break;
            int& res = TempDP[b1];
            int cur = dp[u][k][b1] + dp[v][j][b2] + (b1 != b2);
            res = min(res, cur);
          }
      dp[u][i][0] = TempDP[0];
      dp[u][i][1] = TempDP[1];
    }
  }
  return sz;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int cnt = 0;
  int root = -1;
  for (int i = 1; i <= n; i++)
    if (G[i].size() == 1)
      cnt++;
    else
      root = i;
  if (root == -1)
    cout << 1 << endl;
  else {
    Try(root, -1);
    cnt /= 2;
    cout << min(dp[root][cnt][0], dp[root][cnt][1]) << endl;
  }
  return 0;
}
