#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
int root;
vector<int> mp[5005];
int dp[5005][5005][2];
int sz[5005];
void dfs(int x, int pa) {
  if (mp[x].size() == 1) {
    sz[x] = 1;
    dp[x][0][0] = 0;
    dp[x][1][1] = 0;
    return;
  }
  dp[x][0][0] = dp[x][0][1] = 0;
  for (int c : mp[x])
    if (c != pa) {
      dfs(c, x);
      int tmp[5005][2];
      for (int(i) = 0; (i) < (int)(5005); (i)++)
        for (int(j) = 0; (j) < (int)(2); (j)++) tmp[i][j] = (1 << 30);
      for (int i = sz[x]; i >= 0; i--) {
        for (int j = sz[c]; j >= 0; j--) {
          tmp[i + j][0] = min(tmp[i + j][0],
                              dp[x][i][0] + min(dp[c][j][0], dp[c][j][1] + 1));
          tmp[i + j][1] = min(tmp[i + j][1],
                              dp[x][i][1] + min(dp[c][j][0] + 1, dp[c][j][1]));
        }
      }
      sz[x] += sz[c];
      for (int(i) = 0; (i) < (int)(sz[x] + 1); (i)++)
        for (int(j) = 0; (j) < (int)(2); (j)++) dp[x][i][j] = tmp[i][j];
    }
}
void fmain() {
  scanf("%d", &n);
  if (n == 2) {
    puts("1");
    return;
  }
  for (int i = 0, u, v; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    mp[u].push_back(v);
    mp[v].push_back(u);
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (mp[i].size() != 1) {
      root = i;
      break;
    }
  for (int(i) = 0; (i) < (int)(5005); (i)++)
    for (int(j) = 0; (j) < (int)(5005); (j)++)
      for (int(k) = 0; (k) < (int)(2); (k)++) dp[i][j][k] = (1 << 30);
  dfs(root, 0);
  int cnt = sz[root] / 2;
  int ans = min(dp[root][cnt][0], dp[root][cnt][1]);
  printf("%d\n", ans);
}
int main() {
  fmain();
  return 0;
}
