#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5500;
int n, m;
vector<int> g[MAXN];
int sz[MAXN];
int f[MAXN][MAXN][2];
int t[MAXN][2];
void dfs(int u, int p) {
  for (int i = 0; i <= m; i++) f[u][i][0] = f[u][i][1] = n;
  if (g[u].size() == 1)
    f[u][0][0] = f[u][1][1] = 0, sz[u] = 1;
  else
    f[u][0][0] = f[u][0][1] = 0, sz[u] = 0;
  for (int v : g[u])
    if (v != p) {
      dfs(v, u);
      memcpy(t, f[u], sizeof t);
      for (int i = 0; i <= m; i++) f[u][i][0] = f[u][i][1] = n;
      for (int i = 0; i <= sz[u] && i <= m; i++)
        for (int j = 0; j <= sz[v] && i + j <= m; j++) {
          f[u][i + j][0] = min(f[u][i + j][0], t[i][0] + f[v][j][0]);
          f[u][i + j][0] = min(f[u][i + j][0], t[i][0] + f[v][j][1] + 1);
          f[u][i + j][1] = min(f[u][i + j][1], t[i][1] + f[v][j][0] + 1);
          f[u][i + j][1] = min(f[u][i + j][1], t[i][1] + f[v][j][1]);
        }
      sz[u] += sz[v];
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int rt = 1;
  for (int i = 1; i <= n; i++)
    if (g[i].size() == 1)
      m++;
    else
      rt = i;
  dfs(rt, 0);
  printf("%d\n", f[rt][m / 2][0]);
  return 0;
}
