#include <bits/stdc++.h>
using namespace std;
vector<int> graph[5005], dp[5005][2];
void func(vector<int> &a, vector<int> &b, vector<int> &tt) {
  tt.clear();
  int i, j;
  tt.push_back(2000000000);
  for (i = 0; i < a.size() + b.size() - 2; i++) tt.push_back(2000000000);
  for (i = 0; i < a.size(); i++)
    for (j = 0; j < b.size(); j++) tt[i + j] = min(tt[i + j], a[i] + b[j]);
  return;
}
void solve(int now, int from) {
  int i, j, k;
  for (i = 0; i < graph[now].size(); i++) {
    int to = graph[now][i];
    if (graph[to].size() == 1 || to == from) continue;
    solve(to, now);
  }
  vector<int> temp[2];
  for (j = 0; j < 2; j++) {
    vector<int> &v = dp[now][j];
    for (i = 0; i < graph[now].size(); i++) {
      int to = graph[now][i];
      if (to == from) continue;
      if (graph[to].size() == 1) {
        if (v.size() == 0) {
          v.push_back((j != 1));
          v.push_back((j != 0));
        } else {
          temp[0].clear();
          temp[0].push_back(v[0] + (j != 1));
          for (k = 1; k < v.size(); k++) {
            temp[0].push_back(min(v[k - 1] + (j != 0), v[k] + (j != 1)));
          }
          temp[0].push_back(v[v.size() - 1] + (j != 0));
          for (k = 0; k < v.size(); k++) v[k] = temp[0][k];
          v.push_back(temp[0][v.size()]);
        }
        continue;
      }
      if (v.size() == 0) {
        v.push_back(0);
      }
      for (k = 0; k < 2; k++) func(v, dp[to][k], temp[k]);
      v.clear();
      for (k = 0; k < temp[0].size(); k++)
        v.push_back(min(temp[0][k] + (j != 0), temp[1][k] + (j != 1)));
    }
  }
  return;
}
int main() {
  int i, n, leaf = 0;
  scanf("%d", &n);
  for (i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }
  int root;
  for (i = 0; i < n; i++) {
    if (graph[i].size() > 1) {
      root = i;
    } else
      leaf++;
  }
  solve(root, -1);
  cout << min(dp[root][0][leaf / 2], dp[root][1][leaf / 2]) << endl;
  return 0;
}
