#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
struct sp {
  int q;
  sp *w;
  sp(int q, sp *w) {
    this->q = q;
    this->w = w;
  }
};
sp *a[N];
int *f[N][2], num_deadlocks[N];
void calc_num_v(int q, int par) {
  num_deadlocks[q] = 0;
  for (sp *c = a[q]; c; c = c->w) {
    if (c->q != par) {
      calc_num_v(c->q, q);
      num_deadlocks[q] += num_deadlocks[c->q];
    }
  }
  if (num_deadlocks[q] == 0) {
    num_deadlocks[q]++;
  }
}
int buff[N * 2 + 1];
void calc(int q, int par) {
  int w, e, r;
  for (w = 0; w < 2; w++) {
    f[q][w] = new int[num_deadlocks[q] * 2 + 1];
    for (e = 0; e < num_deadlocks[q] * 2 + 1; e++) {
      f[q][w][e] = 1 << 30;
    }
    f[q][w][num_deadlocks[q]] = 0;
  }
  int lim = 0, new_lim, v1, v2, w1, w2, shift;
  int lAns;
  v1 = num_deadlocks[q];
  for (sp *c = a[q]; c; c = c->w) {
    if (c->q != par) {
      calc(c->q, q);
      v2 = num_deadlocks[c->q];
      new_lim = lim + v2;
      for (e = 0; e < 2; e++) {
        for (w = v1 - new_lim; w <= v1 + new_lim; w++) {
          buff[w] = 1 << 20;
        }
        for (r = 0; r < 2; r++) {
          for (w1 = v1 - lim; w1 <= v1 + lim; w1++) {
            for (w2 = 0; w2 < v2 * 2 + 1; w2++) {
              shift = w1 + w2 - v2;
              lAns = f[q][e][w1] + f[c->q][r][w2] + (e != r);
              buff[shift] = min(buff[shift], lAns);
            }
          }
        }
        for (w = v1 - new_lim; w <= v1 + new_lim; w++) {
          f[q][e][w] = buff[w];
        }
      }
      lim = new_lim;
    }
  }
  if (lim == 0) {
    for (w = 0; w < 2; w++) {
      f[q][w][0] = 0;
      f[q][w][1] = 1 << 20;
      f[q][w][2] = 0;
      f[q][w][2 - w * 2] = 1 << 20;
    }
  }
}
int main() {
  int q, w, e, r, t;
  scanf("%d", &q);
  for (w = 0; w < q; w++) {
    a[w] = 0;
  }
  for (w = 1; w < q; w++) {
    scanf("%d%d", &e, &r);
    e--;
    r--;
    a[e] = new sp(r, a[e]);
    a[r] = new sp(e, a[r]);
  }
  if (q == 2) {
    cout << 1;
    return 0;
  }
  sp *c;
  for (w = 0; w < q; w++) {
    r = 0;
    for (c = a[w]; c; c = c->w) {
      r++;
    }
    if (r > 1) {
      break;
    }
  }
  calc_num_v(w, -1);
  calc(w, -1);
  r = num_deadlocks[w];
  cout << max(f[w][0][r], f[w][1][r]);
  return 0;
}
