#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
constexpr ll mod = 1e9 + 7;
constexpr int N = 5010;
int h[N], e[2 * N], ne[2 * N], idx;
void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; }
int f[N][N][2], sz[N], g[N][2];
int deg[N], n;
void dfs(int u, int fa) {
  if (deg[u] == 1) {
    sz[u] = 1;
    f[u][0][0] = 0;
    f[u][1][1] = 0;
  } else
    f[u][0][0] = f[u][0][1] = 0;
  for (int i = h[u]; i != -1; i = ne[i]) {
    int v = e[i];
    if (v == fa) continue;
    dfs(v, u);
    for (int j = 0; j <= sz[u] + sz[v]; j++) g[j][0] = g[j][1] = 0x3f3f3f3f;
    for (int j = 0; j <= sz[u]; j++)
      for (int k = 0; k <= sz[v]; k++) {
        g[j + k][0] = min(g[j + k][0], f[u][j][0] + f[v][k][1] + 1);
        g[j + k][0] = min(g[j + k][0], f[u][j][0] + f[v][k][0]);
        g[j + k][1] = min(g[j + k][1], f[u][j][1] + f[v][k][0] + 1);
        g[j + k][1] = min(g[j + k][1], f[u][j][1] + f[v][k][1]);
      }
    for (int j = 0; j <= sz[u] + sz[v]; j++)
      f[u][j][0] = g[j][0], f[u][j][1] = g[j][1];
    sz[u] += sz[v];
  }
}
int main() {
  int T = 1;
  while (T--) {
    cin >> n;
    memset(h, -1, sizeof h);
    memset(f, 0x3f, sizeof f);
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      add(u, v), add(v, u);
      deg[u]++;
      deg[v]++;
    }
    int root = 1;
    while (deg[root] == 1) root++;
    dfs(root, 0);
    cout << min(f[root][sz[root] / 2][0], f[root][sz[root] / 2][1]) << '\n';
  }
  return 0;
}
