#include <bits/stdc++.h>
using namespace std;
void load() {}
int n;
const int N = 5100;
int dp[N][N][2], cnt[N];
vector<int> ed[N];
void dfs(int u, int p) {
  for (int i = 1; i <= n; ++i) dp[u][i][0] = dp[u][i][1] = 1e9;
  if (ed[u].size() == 1) cnt[u] = 1, dp[u][1][1] = 0, dp[u][0][1] = 1e9;
  for (int v : ed[u]) {
    if (v == p) continue;
    dfs(v, u);
    cnt[u] += cnt[v];
    for (int i = cnt[u]; i >= 0; --i) {
      int max1 = 1e9, max0 = 1e9;
      for (int j = 0; j <= min(cnt[v], i); ++j) {
        max0 = min(max0, min(dp[u][i - j][0] + dp[v][j][0],
                             dp[u][i - j][0] + dp[v][j][1] + 1));
        max1 = min(max1, min(dp[u][i - j][1] + dp[v][j][1],
                             dp[u][i - j][1] + dp[v][j][0] + 1));
      }
      dp[u][i][0] = max0;
      dp[u][i][1] = max1;
    }
  }
}
void trungtt() {
  scanf("%d", &n);
  if (n == 2) {
    printf("1");
    return;
  }
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    ed[u].push_back(v);
    ed[v].push_back(u);
  }
  int root = 1;
  while (ed[root].size() == 1) ++root;
  dfs(root, 0);
  printf("%d", min(dp[root][cnt[root] / 2][1], dp[root][cnt[root] / 2][1]));
  return;
}
int main() {
  load();
  trungtt();
  return 0;
}
