#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005, maxm = 200005, maxt = 262205;
int n, f[maxn], h[maxn], tot, e[maxm], nxt[maxm], t[maxt], ans, dfn[maxn],
    size[maxn], mask[maxt], g[maxn];
bool p[maxm];
char c;
int read() {
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  int x = c - 48;
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
  return x;
}
void add(int x, int y, bool bz) {
  e[++tot] = y;
  nxt[tot] = h[x];
  p[tot] = bz;
  h[x] = tot;
}
void init1(int x, int fa) {
  f[x] = 0;
  dfn[x] = ++tot;
  for (int i = h[x]; i; i = nxt[i])
    if (e[i] != fa) {
      init1(e[i], x);
      size[x] += size[e[i]] + 1;
      f[x] += f[e[i]] + (p[i] ^ 1);
    }
}
void change(int l, int r, int a, int b, int v, int x) {
  if (l == a && r == b) {
    mask[x] += v;
    t[x] += v;
    return;
  }
  int mid = l + r >> 1, lt = x << 1, rt = lt | 1;
  if (mask[x]) {
    mask[lt] += mask[x];
    t[lt] += mask[x];
    mask[rt] += mask[x];
    t[rt] += mask[x];
    mask[x] = 0;
  }
  if (b <= mid)
    change(l, mid, a, b, v, lt);
  else if (a > mid)
    change(mid + 1, r, a, b, v, rt);
  else {
    change(l, mid, a, mid, v, lt);
    change(mid + 1, r, mid + 1, b, v, rt);
  }
  t[x] = min(t[lt], t[rt]);
}
int query(int l, int r, int a, int b, int x) {
  if (l == a && r == b) return t[x];
  int mid = l + r >> 1, lt = x << 1, rt = lt | 1;
  if (mask[x]) {
    mask[lt] += mask[x];
    t[lt] += mask[x];
    mask[rt] += mask[x];
    t[rt] += mask[x];
    mask[x] = 0;
  }
  if (b <= mid) return query(l, mid, a, b, lt);
  if (a > mid) return query(mid + 1, r, a, b, rt);
  return min(query(l, mid, a, mid, lt), query(mid + 1, r, mid + 1, b, rt));
}
void init2(int x, int fa) {
  change(1, n, dfn[x], dfn[x], g[x], 1);
  for (int i = h[x]; i; i = nxt[i])
    if (e[i] != fa) {
      f[e[i]] = f[x] - (p[i] ^ 1) + p[i];
      g[e[i]] = g[x] - (p[i] ^ 1) + p[i];
      init2(e[i], x);
    }
}
void dfs(int x, int fa) {
  int m1 = 0, m2 = 0, t;
  for (int i = h[x]; i; i = nxt[i])
    if (e[i] != fa) {
      ans = min(ans, f[x] - (p[i] ^ 1));
      t = (p[i] ^ 1) - p[i];
      change(1, n, dfn[e[i]], dfn[e[i]] + size[e[i]], t, 1);
      if (dfn[e[i]] > 1) change(1, n, 1, dfn[e[i]] - 1, t, 1);
      if (dfn[e[i]] + size[e[i]] < n)
        change(1, n, dfn[e[i]] + size[e[i]] + 1, n, t, 1);
      dfs(e[i], x);
      change(1, n, dfn[e[i]], dfn[e[i]] + size[e[i]], -t, 1);
      if (dfn[e[i]] > 1) change(1, n, 1, dfn[e[i]] - 1, -t, 1);
      if (dfn[e[i]] + size[e[i]] < n)
        change(1, n, dfn[e[i]] + size[e[i]] + 1, n, -t, 1);
      t = query(1, n, dfn[e[i]], dfn[e[i]] + size[e[i]], 1);
      if (t < m1) {
        m2 = m1;
        m1 = t;
      } else if (t < m2)
        m2 = t;
    }
  t = 1e9;
  if (dfn[x] > 1) t = query(1, n, 1, dfn[x] - 1, 1);
  if (dfn[x] + size[x] < n) t = min(t, query(1, n, dfn[x] + size[x] + 1, n, 1));
  if (t < m1) {
    m2 = m1;
    m1 = t;
  } else if (t < m2)
    m2 = t;
  ans = min(ans, f[x] + m1 + m2);
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    add(x, y, 1);
    add(y, x, 0);
  }
  tot = 0;
  init1(1, 0);
  init2(1, 0);
  ans = f[1];
  dfs(1, 0);
  printf("%d\n", ans);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
