#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3001;
const int INF = 0x3f3f3f3f;
const int NO = 0, YES = 1, OTHER = 2;
struct Edge {
  int to;
  bool right;
};
struct Visit {
  int place, val;
};
int n;
vector<vector<Edge> > adj;
int best(int root) {
  static bool v[MAXN];
  memset(v, false, sizeof(v));
  int supplementary = 0, bad = 0;
  stack<Visit> st;
  st.push((Visit){root, 0});
  v[root] = true;
  while (!st.empty()) {
    Visit cur = st.top();
    st.pop();
    supplementary = min(supplementary, cur.val);
    for (int i = 0; i < adj[cur.place].size(); i++) {
      if (!v[adj[cur.place][i].to]) {
        if (!adj[cur.place][i].right) bad++;
        v[adj[cur.place][i].to] = true;
        st.push((Visit){adj[cur.place][i].to,
                        min(0, cur.val + (adj[cur.place][i].right ? 1 : -1))});
      }
    }
  }
  return bad + supplementary;
}
int main() {
  cin >> n;
  adj.resize(n);
  int t, f;
  for (int i = 1; i < n; i++) {
    cin >> f >> t;
    adj[f - 1].push_back((Edge){t - 1, true});
    adj[t - 1].push_back((Edge){f - 1, false});
  }
  int ans = INF;
  for (int i = 0; i < n; i++) ans = min(ans, best(i));
  cout << ans << endl;
  return 0;
}
