#include <bits/stdc++.h>
using namespace std;
vector<int> g[5050];
int A[5050][2550], B[5050][2550], tmp[2550], all[2550];
int Amax[5050], Bmax[5050];
int chk[5050];
void dfs(int node, int parent = -1) {
  chk[node] = 1;
  for (int i = 0; i < g[node].size(); i++) {
    if (chk[g[node][i]]) continue;
    dfs(g[node][i], node);
  }
  if (g[node].size() == 1) {
    A[node][1] = B[node][0] = 0;
    Amax[node] = 1;
    Bmax[node] = 0;
  } else {
    A[node][0] = B[node][0] = 0;
  }
  for (int i = 0; i < g[node].size(); i++) {
    if (g[node][i] == parent) continue;
    int to = g[node][i];
    for (int j = 0; j <= ((Amax[to]) > (Bmax[to]) ? (Amax[to]) : (Bmax[to]));
         j++) {
      all[j] = ((A[to][j]) < (B[to][j] + 1) ? (A[to][j]) : (B[to][j] + 1));
    }
    int iterMax = Amax[node];
    for (int j = 0; j <= Amax[node]; j++) {
      for (int k = 0; k <= max(Amax[to], Bmax[to]); k++) {
        if (j + k > 2500) continue;
        tmp[j + k] =
            ((tmp[j + k]) < (A[node][j] + all[k]) ? (tmp[j + k])
                                                  : (A[node][j] + all[k]));
        iterMax = ((iterMax) > (j + k) ? (iterMax) : (j + k));
      }
    }
    Amax[node] = iterMax;
    for (int j = 0; j <= iterMax; j++) {
      A[node][j] = tmp[j];
      tmp[j] = 0x7fffffff / 2;
    }
  }
  for (int i = 0; i < g[node].size(); i++) {
    if (g[node][i] == parent) continue;
    int to = g[node][i];
    for (int j = 0; j <= ((Amax[to]) > (Bmax[to]) ? (Amax[to]) : (Bmax[to]));
         j++) {
      all[j] = ((A[to][j] + 1) < (B[to][j]) ? (A[to][j] + 1) : (B[to][j]));
    }
    int iterMax = Bmax[node];
    for (int j = 0; j <= Bmax[node]; j++) {
      for (int k = 0; k <= max(Amax[to], Bmax[to]); k++) {
        if (j + k > 2500) continue;
        tmp[j + k] =
            ((tmp[j + k]) < (B[node][j] + all[k]) ? (tmp[j + k])
                                                  : (B[node][j] + all[k]));
        iterMax = ((iterMax) > (j + k) ? (iterMax) : (j + k));
      }
    }
    Bmax[node] = iterMax;
    for (int j = 0; j <= iterMax; j++) {
      B[node][j] = tmp[j];
      tmp[j] = 0x7fffffff / 2;
    }
  }
}
int main() {
  int n, leaf = 0;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    Amax[i] = Bmax[i] = 0;
    for (int j = 0; j <= 2500; j++) {
      A[i][j] = B[i][j] = 0x7fffffff / 2;
      tmp[j] = 0x7fffffff / 2;
    }
    if (g[i].size() == 1) leaf++;
  }
  dfs(1);
  printf("%d\n", ((A[1][leaf / 2]) < (B[1][leaf / 2]) ? (A[1][leaf / 2])
                                                      : (B[1][leaf / 2])));
  return 0;
}
