#include <bits/stdc++.h>
using namespace std;
struct IO {
  char buf[(1 << 20)], *p1, *p2;
  char pbuf[(1 << 20)], *pp;
  IO() : p1(buf), p2(buf), pp(pbuf) {}
  inline char gc() {
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, (1 << 20), stdin);
    return p1 == p2 ? ' ' : *p1++;
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T &x) {
    register double tmp = 1;
    register bool sign = 0;
    x = 0;
    register char ch = gc();
    for (; !(ch >= '0' && ch <= '9'); ch = gc())
      if (ch == '-') sign = 1;
    for (; (ch >= '0' && ch <= '9'); ch = gc()) x = x * 10 + (ch - '0');
    if (ch == '.')
      for (ch = gc(); (ch >= '0' && ch <= '9'); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if (sign) x = -x;
  }
  inline void read(char *s) {
    register char ch = gc();
    for (; blank(ch); ch = gc())
      ;
    for (; !blank(ch); ch = gc()) *s++ = ch;
    *s = 0;
  }
  inline void read(char &c) {
    for (c = gc(); blank(c); c = gc())
      ;
  }
  template <class t>
  inline void write(t x) {
    if (x < 0)
      putchar('-'), write(-x);
    else {
      if (x > 9) write(x / 10);
      putchar('0' + x % 10);
    }
  }
} io;
const int mod = 1e9 + 7;
const int mo = 998244353;
const int N = 5005;
int n, m, ans, tot, f[N][N][2], siz[N], leaf[N];
vector<int> G[N];
inline void Dfs(int u, int fa) {
  siz[u] = 1;
  leaf[u] = ((int)G[u].size() == 1);
  for (int i = (0); i <= ((int)G[u].size() - 1); i++) {
    int v = G[u][i];
    if (G[u][i] ^ fa) {
      Dfs(v, u);
      siz[u] += siz[v];
      leaf[u] += leaf[v];
    }
  }
}
inline void dp(int u, int fa) {
  for (int i = (0); i <= ((int)G[u].size() - 1); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    dp(v, u);
    leaf[u] += leaf[v];
  }
  if ((int)G[u].size() == 1) {
    f[u][1][1] = f[u][0][0] = 0;
    leaf[u] = 1;
    return;
  } else
    f[u][0][0] = f[u][0][1] = 0;
  int flg = 0;
  for (int i = (0); i <= ((int)G[u].size() - 1); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    for (int j = (leaf[u]); j >= (0); j--) {
      int mia = 1e9, mib = 1e9;
      for (int k = (0); k <= (leaf[v]); k++) {
        if (k > j) break;
        mia = min(mia, f[u][j - k][1] + f[v][k][0] + 1);
        mia = min(mia, f[u][j - k][1] + f[v][k][1]);
        mib = min(mib, f[u][j - k][0] + f[v][k][1] + 1);
        mib = min(mib, f[u][j - k][0] + f[v][k][0]);
      }
      f[u][j][1] = mia;
      f[u][j][0] = mib;
    }
  }
}
int main() {
  srand(time(NULL));
  io.read(n);
  for (int i = (1); i <= (n - 1); i++) {
    int x, y;
    io.read(x), io.read(y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  int Rt = rand() % n + 1;
  while ((int)G[Rt].size() <= 1) Rt = rand() % n + 1;
  Dfs(Rt, 0);
  tot = leaf[Rt];
  for (int i = (1); i <= (n); i++) leaf[i] = 0;
  memset(f, 127 / 3, sizeof(f));
  dp(Rt, 0);
  io.write(min(f[Rt][tot >> 1][0], f[Rt][tot >> 1][1]));
  return 0;
}
