#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template <class A>
string to_string(complex<A> c) {
  stringstream ss;
  ss << c;
  return ss.str();
}
string to_string(vector<bool> v) {
  string res = "{";
  for (int i = 0; i < (int)v.size(); i++) res += char('0' + v[i]);
  res += "}";
  return res;
}
template <size_t SZ>
string to_string(bitset<SZ> b) {
  string res = "";
  for (size_t i = 0; i < SZ; i++) res += char('0' + b[i]);
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p);
template <class T>
string to_string(T v) {
  bool fst = 1;
  string res = "{";
  for (const auto& x : v) {
    if (!fst) res += ", ";
    fst = 0;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
const int MAXN = 3e3 + 10;
vector<pair<int, int>> adj[MAXN];
int n;
int pre_dfs(int v, int p) {
  int ret = 0;
  for (auto i : adj[v]) {
    if (i.first == p) {
      continue;
    }
    ret += i.second;
    ret += pre_dfs(i.first, v);
  }
  return ret;
}
int dfs(int v, int p, int last) {
  int ret = last;
  for (auto i : adj[v]) {
    if (i.first == p) {
      continue;
    }
    if (i.second) {
      ret = min(ret, dfs(i.first, v, last - 1));
    } else {
      ret = min(ret, dfs(i.first, v, last + 1));
    }
  }
  return ret;
}
inline int solve(int v, int block) {
  int root = pre_dfs(v, block);
  return dfs(v, block, root);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  if (n == 1) {
    cout << 0 << '\n';
    return 0;
  }
  vector<pair<int, int>> edges(n);
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back({v, 0});
    adj[v].push_back({u, 1});
    edges[i] = {u, v};
  }
  int ans = INT_MAX;
  for (int i = 1; i < n; i++) {
    int a1 = solve(edges[i].first, edges[i].second);
    int a2 = solve(edges[i].second, edges[i].first);
    ans = min(ans, a1 + a2);
  }
  cout << ans << '\n';
}
