#include <bits/stdc++.h>
using namespace std;
int const N = 5001, INF = 987654321;
int deg[N], leaf;
vector<vector<int>> g;
vector<pair<int, int>> dfs(int here, int p) {
  vector<pair<int, int>> d;
  if (deg[here] == 1) {
    ++leaf;
    d.push_back(pair<int, int>(INF, 0));
    d.push_back(pair<int, int>(0, INF));
    return d;
  }
  d.push_back(pair<int, int>(0, 0));
  for (auto there : g[here]) {
    if (there == p) continue;
    vector<pair<int, int>> dchild = dfs(there, here);
    vector<pair<int, int>> dnew(d.size() + dchild.size() - 1,
                                pair<int, int>(INF, INF));
    for (int i = 0; i < d.size(); ++i) {
      for (int j = 0; j < dchild.size(); ++j) {
        dnew[i + j].first =
            min(dnew[i + j].first, min(d[i].first + dchild[j].first,
                                       d[i].first + dchild[j].second + 1));
        dnew[i + j].second =
            min(dnew[i + j].second, min(d[i].second + dchild[j].first + 1,
                                        d[i].second + dchild[j].second));
      }
    }
    d.swap(dnew);
  }
  return d;
}
int main() {
  int n;
  scanf("%d", &n);
  if (n == 2) {
    printf("1");
    return 0;
  }
  g = vector<vector<int>>(n + 1);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
    ++deg[x];
    ++deg[y];
  }
  for (int i = 1; i <= n; ++i) {
    if (deg[i] != 1) {
      vector<pair<int, int>> d = dfs(i, 0);
      printf("%d", min(d[leaf / 2].first, d[leaf / 2].second));
      return 0;
    }
  }
  return 0;
}
