#include <bits/stdc++.h>
using namespace std;
const int N = 5001;
vector<int> adj[N];
int sz[N], f[N][N];
int n;
void dfs(int u, int fa) {
  if (adj[u].size() == 1) sz[u] = 1;
  int i, v;
  for (i = 1; i <= n; i++) f[u][i] = 0x3f3f3f3f;
  for (i = 0; i < adj[u].size(); i++) {
    v = adj[u][i];
    if (v == fa) continue;
    dfs(v, u);
    for (int i = sz[u]; i >= 0; i--)
      for (int j = 0; j <= sz[v]; j++)
        f[u][i + j] = min(f[u][i + j], f[u][i] + f[v][j]);
    sz[u] += sz[v];
  }
  for (i = 0; i <= sz[u]; i++) f[u][i] = min(f[u][i], f[u][sz[u] - i] + 1);
}
int main() {
  scanf("%d", &n);
  if (n == 2) {
    puts("1");
    return 0;
  }
  int u, v, i, root = 1;
  for (i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  while (adj[root].size() == 1) root++;
  dfs(root, 0);
  printf("%d", f[root][sz[root] / 2]);
  return 0;
}
