#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int SIZE = 5004;
int n;
vector<vector<int> > children;
int par[SIZE];
vector<vector<int> > g;
int deg[SIZE], numleaves[SIZE], nextchild[SIZE];
bool vis[SIZE];
int dp1[SIZE][SIZE / 2][2], dp2[SIZE][SIZE / 2][2];
void dfstree(int u) {
  numleaves[u] = deg[u] == 1;
  vis[u] = 1;
  int prevchild = -1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (vis[v]) continue;
    if (prevchild != -1) nextchild[prevchild] = v;
    children[u].push_back(v);
    par[v] = u;
    dfstree(v);
    numleaves[u] += numleaves[v];
    prevchild = v;
  }
}
int go2(int s, int cnt, int col);
int go1(int u, int cnt, int col);
int go1(int u, int cnt, int col) {
  int &ret = dp1[u][cnt][col];
  if (ret != -1) return ret;
  if (numleaves[u] < cnt)
    ret = INF;
  else if ((children[u].size()) == 0)
    ret = cnt == 0 ? col == 1 ? 0 : INF : col == 0 ? 0 : INF;
  else
    ret = go2(children[u][0], cnt, col);
  return ret;
}
int go2(int s, int cnt, int col) {
  int &ret = dp2[s][cnt][col];
  if (ret != -1) return ret;
  ret = INF;
  if (nextchild[s] == -1) {
    ret = min(go1(s, cnt, col), go1(s, cnt, col ^ 1) + 1);
  } else {
    int ns = nextchild[s];
    int nl = numleaves[s];
    for (int i = 0; i < min(cnt, nl) + 1; i++) {
      for (int ncol = 0; ncol < 2; ncol++) {
        ret = min(ret, go1(s, i, ncol) + (ncol != col) + go2(ns, cnt - i, col));
      }
    }
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  memset(deg, 0, sizeof(deg));
  memset(dp1, -1, sizeof(dp1));
  memset(dp2, -1, sizeof(dp2));
  memset(vis, 0, sizeof(vis));
  memset(nextchild, -1, sizeof(nextchild));
  g.clear();
  g.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
    deg[x]++;
    deg[y]++;
  }
  if (n == 2) {
    printf("1\n");
    return 0;
  }
  children.clear();
  children.resize(n);
  memset(par, -1, sizeof(par));
  int root = 0;
  while (deg[root] <= 1) root++;
  dfstree(root);
  printf("%d\n", min(go1(root, numleaves[root] / 2, 0),
                     go1(root, numleaves[root] / 2, 1)));
  return 0;
}
