#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> adj_list;
vector<int> leaves, parents;
int dfs(int curr, int p) {
  parents[curr] = p;
  if (adj_list[curr].size() == 1) return leaves[curr] = 1;
  int sum = 0;
  for (int c : adj_list[curr])
    if (c != p) sum += dfs(c, curr);
  return leaves[curr] = sum;
}
int g(int curr, int ci, int rem);
vector<vector<int>> fdp;
int f(int curr, int rem) {
  if (adj_list[curr].size() == 1) return rem == 1 ? 0 : 1e8;
  if (fdp[curr][rem] != -1) return fdp[curr][rem];
  return fdp[curr][rem] = g(curr, 0, rem);
}
vector<vector<vector<int>>> gdp;
int g(int curr, int ci, int rem) {
  if (ci == adj_list[curr].size()) return rem ? 1e8 : 0;
  if (gdp[curr][ci][rem] != -1) return gdp[curr][ci][rem];
  int c = adj_list[curr][ci];
  if (c == parents[curr]) return g(curr, ci + 1, rem);
  int best = 1e8;
  for (int place = 0; place <= rem && place <= leaves[c]; ++place) {
    best = min(best, f(c, place) + g(curr, ci + 1, rem - place));
    best =
        min(best, 1 + f(c, leaves[c] - place) + g(curr, ci + 1, rem - place));
  }
  return gdp[curr][ci][rem] = best;
}
int main() {
  cin >> n;
  if (n <= 2) {
    cout << (n - 1) << endl;
    return 0;
  }
  adj_list = vector<vector<int>>(n);
  parents = vector<int>(n);
  leaves = parents;
  fdp = vector<vector<int>>(n, vector<int>(n, -1));
  gdp = vector<vector<vector<int>>>(n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    adj_list[x].push_back(y);
    adj_list[y].push_back(x);
  }
  for (int i = 0; i < n; ++i)
    gdp[i] = vector<vector<int>>(adj_list[i].size(), vector<int>(n, -1));
  int root = 0;
  while (adj_list[root].size() == 1) ++root;
  dfs(root, root);
  cout << f(root, leaves[root] / 2) << endl;
  return 0;
}
