#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, inv;
  bool str;
  edge(int to = 0, int inv = 0, bool str = false)
      : to(to), inv(inv), str(str) {}
};
vector<vector<int> > dp;
vector<vector<int> > calc;
vector<vector<edge> > gr;
vector<int> sum;
int fdp(int v, int i);
int fcalc(int v, int i) {
  if (calc[v][i] != -1) return calc[v][i];
  edge cur = gr[v][i];
  calc[v][i] = fdp(cur.to, cur.inv);
  if (!cur.str) calc[v][i]++;
  return calc[v][i];
}
int fdp(int v, int i) {
  if (dp[v][i] != -1) return dp[v][i];
  int res = 0;
  for (int j = 0; j < gr[v].size(); j++) {
    if (j == i) continue;
    res += fcalc(v, j);
  }
  return dp[v][i] = res;
}
vector<int> st;
vector<int> sts;
int cnt[2];
int minn = int(1e9);
void dfs2(int v, int i, int add, int cur) {
  st.push_back(v);
  if (st.size() == 1)
    minn = min(minn, sum[v]);
  else {
    int tmp = fdp(v, i);
    minn = min(minn, cur + tmp + add);
  }
  for (int j = 0; j < gr[v].size(); j++) {
    if (j == i) continue;
    int newcur = cur + sum[v] - fcalc(v, j);
    if (st.size() != 1) newcur -= fcalc(v, i);
    if (gr[v][j].str)
      sts.push_back(1);
    else
      sts.push_back(0);
    cnt[sts.back()]++;
    int newadd = (sts.back() == 0) ? min(add, cnt[0]) : min(add + 1, cnt[0]);
    dfs2(gr[v][j].to, gr[v][j].inv, newadd, newcur);
    cnt[sts.back()]--;
    sts.pop_back();
  }
  st.pop_back();
}
int main() {
  int n;
  cin >> n;
  gr.resize(n);
  dp.resize(n);
  calc.resize(n);
  sum.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    gr[a].push_back(edge(b, gr[b].size(), true));
    gr[b].push_back(edge(a, gr[a].size() - 1, false));
  }
  for (int i = 0; i < n; i++) {
    calc[i].assign(gr[i].size(), -1);
    dp[i].assign(gr[i].size(), -1);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < gr[i].size(); j++) sum[i] += fcalc(i, j);
  for (int i = 0; i < n; i++) dfs2(i, -1, 0, 0);
  cout << minn;
  return 0;
}
