#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > graph(5005);
int leaf[5005] = {0};
int c[5005][5005];
int cat[5005][5005];
int dfs(int index, int p) {
  for (int(i) = (0); (i) < (5005); i++) {
    c[index][i] = 1e9;
    cat[index][i] = 1e9;
  }
  leaf[index] = (graph[index].size() == 1);
  c[index][0] = 0;
  cat[index][0] = 0;
  for (int(i) = (0); (i) < (graph[index].size()); i++) {
    int ch = graph[index][i];
    if (ch != p) {
      dfs(ch, index);
      for (int j = 0; j <= leaf[index]; j++) {
        for (int k = 0; k <= leaf[ch]; k++) {
          cat[index][j + k] = min(cat[index][j + k], c[index][j] + c[ch][k]);
        }
        for (int k = 0; k <= leaf[ch]; k++) {
          cat[index][j + k] =
              min(cat[index][j + k], c[index][j] + 1 + c[ch][leaf[ch] - k]);
        }
      }
      leaf[index] += leaf[ch];
      for (int(j) = (0); (j) < (leaf[index]); j++) c[index][j] = cat[index][j];
    }
  }
  return 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int(i) = (0); (i) < (n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  dfs(1, -1);
  cout << c[1][leaf[1] / 2] << endl;
}
