#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> ke[5111];
int f[2][5111][5111];
int sz[5111];
void dfs(int u, int fu) {
  if (((int)((ke[u]).size())) == 1) {
    sz[u] = 1;
    f[0][u][0] = 0;
    f[0][u][1] = 5111;
    f[1][u][1] = 0;
    f[1][u][0] = 5111;
    return;
  }
  for (int v : ke[u])
    if (v != fu) {
      dfs(v, u);
      sz[u] += sz[v];
    }
  for (int color_u = (int)(0), _t = (int)(1); color_u <= _t; color_u++) {
    int g[5111];
    for (int i = (int)(0), _t = (int)(sz[u]); i <= _t; i++) g[i] = 5111;
    g[0] = 0;
    int curNumLeaves = 0;
    for (int v : ke[u])
      if (v != fu) {
        curNumLeaves += sz[v];
        for (int i = (int)(curNumLeaves), _t = (int)(0); i >= _t; i--) {
          g[i] = g[i] + min(f[color_u][v][0], f[1 - color_u][v][0] + 1);
          for (int j = (int)(0), _t = (int)(min(sz[v], i)); j <= _t; j++)
            g[i] = min(g[i], g[i - j] + min(f[color_u][v][j],
                                            f[1 - color_u][v][j] + 1));
        }
      }
    for (int i = (int)(0), _t = (int)(sz[u]); i <= _t; i++)
      f[color_u][u][i] = g[i];
  }
}
bool input() {
  if (cin >> n) {
    for (int i = (int)(1), _t = (int)(n); i <= _t; i++) ke[i].clear();
    for (int i = (int)(2), _t = (int)(n); i <= _t; i++) {
      int u, v;
      cin >> u >> v;
      ke[u].push_back(v);
      ke[v].push_back(u);
    }
    return true;
  } else {
    return false;
  }
}
void solve() {
  if (n == 2) {
    cout << 1 << endl;
    return;
  }
  int root = 1;
  while (ke[root].size() == 1) ++root;
  memset((sz), 0, sizeof(sz));
  dfs(root, -1);
  cout << f[1][root][sz[root] / 2] << endl;
}
int main() {
  ios ::sync_with_stdio(false);
  while (input()) solve();
  return 0;
}
