#include <bits/stdc++.h>
using namespace std;
const int N = 5003;
vector<int> adj[N];
int can[N][N], s[N];
void dfs(int x, int p) {
  s[x] = int((adj[x]).size()) == 1;
  for (int i : adj[x])
    if (i != p) {
      dfs(i, x);
      s[x] += s[i];
    }
  for (int i = (0); i < (N); i++) can[x][i] = 1e9;
  can[x][0] = 0;
  for (int v : adj[x])
    if (v != p)
      for (int j = s[x]; j >= 0; j--)
        for (int u = 0; u <= min(s[v], j); u++)
          can[x][j] = min(can[x][j], can[v][u] + can[x][j - u]);
  for (int i = (0); i < (s[x] + 1); i++)
    can[x][s[x] - i] = min(can[x][s[x] - i], can[x][i] + 1);
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = (0); i < (n - 1); i++) {
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int root = 1;
  while (int((adj[root]).size()) == 1) root++;
  dfs(root, 0);
  printf("%d", n == 2 ? 1 : can[root][s[root] / 2]);
  return 0;
}
