#include <bits/stdc++.h>
using namespace std;
int n, leaf;
vector<int> adj[5005];
int s[5005], d[5005][5005];
void input() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
}
void dfs(int cur, int par) {
  if (adj[cur].size() == 1 && par) s[cur] = d[cur][1] = 1;
  for (int nxt : adj[cur]) {
    if (nxt != par) {
      dfs(nxt, cur);
      for (int j = s[cur]; j >= 0; j--) {
        for (int k = 0; k <= s[nxt]; k++) {
          d[cur][j + k] = min(d[cur][j + k], d[cur][j] + d[nxt][k]);
        }
      }
      s[cur] += s[nxt];
    }
  }
  for (int i = 0; i <= s[cur]; i++)
    d[cur][i] = min(d[cur][i], d[cur][s[cur] - i] + 1);
}
void solve() {
  input();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) d[i][j] = 1e9;
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    if (adj[i].size() == 1) leaf++;
  }
  printf("%d\n", d[1][leaf / 2]);
}
int main(void) {
  solve();
  return 0;
}
