#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const double eps = 1e-6;
const long long mod = 1000000007;
inline string getstr(string &s, long long l, long long r) {
  string ret = "";
  for (long long i = l; i <= r; i++) ret.push_back(s[i]);
  return ret;
}
long long modpow(long long x, long long y, long long md = mod) {
  long long ret = 1;
  do {
    if (y & 1) ret = (long long)ret * x % md;
    x = (long long)x * x % md;
  } while (y >>= 1);
  return ret;
}
long long n, mn;
vector<pair<long long, long long> > g[3003];
long long dfs(long long x, long long p, long long cur, long long mv) {
  long long ret = 0;
  mn = min(mn, cur - mv);
  for (auto to : g[x])
    if (to.first != p) {
      ret += (to.second > 0);
      ret += dfs(to.first, x, cur - to.second, max(mv, cur - to.second));
    }
  return ret;
}
signed main() {
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(make_pair(y, -1));
    g[y].push_back(make_pair(x, 1));
  }
  long long ans = 1e9;
  for (long long i = 1; i <= n; i++) {
    mn = inf;
    ans = min(ans, dfs(i, -1, 0, 0) + mn);
  }
  cout << ans << endl;
  return 0;
}
