#include <bits/stdc++.h>
FILE *in = stdin, *out = stdout;
using namespace std;
int n;
vector<int> son[5005];
int tot;
vector<int> edge[5005];
int dy[5005][2][5005];
int leaf[5005];
int visit[5005];
void input() {
  fscanf(in, "%d", &n);
  for (int i = (1); i <= (n - 1); i++) {
    int x, y;
    fscanf(in, "%d", &x), fscanf(in, "%d", &y);
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
}
int temp[2][5005];
void go(int x) {
  visit[x] = 1;
  int flag = 0;
  for (auto &i : edge[x]) {
    if (visit[i]) continue;
    go(i);
    if (flag == 0) dy[x][0][0] = dy[x][1][0] = 0;
    flag = 1;
    for (int j = (0); j <= (leaf[x] + leaf[i]); j++)
      temp[0][j] = temp[1][j] = 0x7fffffff;
    for (int p1 = (0); p1 <= (1); p1++)
      for (int p2 = (0); p2 <= (1); p2++)
        for (int j = (0); j <= (leaf[x]); j++)
          for (int k = (0); k <= (leaf[i]); k++)
            if (dy[x][p1][j] != 0x7fffffff && dy[i][p2][k] != 0x7fffffff)
              temp[p1][j + k] =
                  min(temp[p1][j + k],
                      dy[x][p1][j] + dy[i][p2][k] + (p1 == p2 ? 0 : 1));
    for (int j = (0); j <= (leaf[x] + leaf[i]); j++)
      for (int k = (0); k <= (1); k++) dy[x][k][j] = temp[k][j];
    leaf[x] += leaf[i];
  }
  if (flag == 0) {
    leaf[x] = 1;
    dy[x][0][0] = 0;
    dy[x][1][1] = 0;
    tot++;
  }
}
void pro() {
  for (int i = (0); i <= (n); i++)
    for (int j = (0); j <= (n); j++) dy[i][0][j] = dy[i][1][j] = 0x7fffffff;
  for (int i = (1); i <= (n); i++)
    if (edge[i].size() > 1) {
      go(i);
      fprintf(out, "%d", dy[i][1][tot / 2]);
      return;
    }
}
int main() {
  input();
  if (n == 2)
    fprintf(out, "1");
  else
    pro();
  return 0;
}
