#include <bits/stdc++.h>
using namespace std;
const int MAX = 5e3 + 9, INF = 1e9 + 9;
int n, a, b, root, dp[MAX][MAX], sz[MAX], dp2[MAX];
vector<int> g[MAX];
void dfs(int v, int p) {
  dp[v][0] = 0;
  for (auto u : g[v])
    if (u != p) {
      dfs(u, v);
      for (int i = 0; i <= sz[v] + sz[u]; i++) dp2[i] = INF;
      for (int i = 0; i <= sz[v]; i++) {
        for (int j = 0; j <= sz[u]; j++)
          dp2[i + j] = min(dp2[i + j], dp[v][i] + dp[u][j]);
        for (int j = 0; j <= sz[u]; j++)
          dp2[i + j] = min(dp2[i + j], dp[v][i] + dp[u][sz[u] - j] + 1);
      }
      sz[v] += sz[u];
      for (int i = 0; i <= sz[v]; i++) dp[v][i] = dp2[i];
    }
  if (g[v].size() == 1) sz[v] = 1;
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++)
    cin >> a >> b, a--, b--, g[a].push_back(b), g[b].push_back(a);
  if (n == 2) return cout << 1, 0;
  for (int i = 0; i < MAX; i++)
    for (int j = 0; j < MAX; j++) dp[i][j] = INF;
  for (int i = 0; i < n; i++)
    if (g[i].size() > 1) root = i;
  dfs(root, -1);
  cout << dp[root][sz[root] / 2];
}
