#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 3007;
struct eT {
  void setd(int _u, int _v, int _l) { u = _u, v = _v, last = _l; }
  int u, v, last;
} edge[MAXN * 2];
int n, ke;
int la[MAXN];
int cr, maxi;
void init();
void input();
void work();
int getans(int rt);
void dfs(int now, int fa, int ua);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d", &n);
  int u, v;
  ke = 1;
  memset(la, -1, sizeof(la));
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    edge[ke].setd(u, v, la[u]);
    la[u] = ke++;
    edge[ke].setd(v, u, la[v]);
    la[v] = ke++;
  }
}
void work() {
  int ans = INF, now;
  for (int i = 1; i <= n; ++i) {
    now = getans(i);
    ans = (((ans) < (now)) ? (ans) : (now));
  }
  printf("%d\n", ans);
}
int getans(int rt) {
  maxi = 0;
  cr = 0;
  dfs(rt, -1, 0);
  return cr - maxi;
}
void dfs(int now, int fa, int ua) {
  maxi = (((maxi) > (ua)) ? (maxi) : (ua));
  int v, va;
  for (int i = la[now]; ~i; i = edge[i].last) {
    if ((v = edge[i].v) ^ fa) {
      if (i & 1) {
        va = ua - 1;
        if (va < 0) va = 0;
      } else {
        ++cr;
        va = ua + 1;
      }
      dfs(v, now, va);
    }
  }
}
