#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795L;
const long double EPS = 1e-8;
char TEMPORARY_CHAR;
const long long INF = 1e17;
const int N = 1 << 17;
inline void input(int& a) {
  a = 0;
  while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') &&
         (TEMPORARY_CHAR != '-')) {
  }
  char neg = 0;
  if (TEMPORARY_CHAR == '-') {
    neg = 1;
    TEMPORARY_CHAR = getchar();
  }
  while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {
    a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0';
    TEMPORARY_CHAR = getchar();
  }
  if (neg) a = -a;
}
inline int nxt() {
  int(ret);
  input((ret));
  ;
  return ret;
}
vector<vector<pair<int, int> > > g;
vector<int> dp1, dp2;
int cnt = 0;
int dfs(int v, int p) {
  int mi1 = dp2[v] - dp1[v], mi2 = 1e9;
  for (int i = 0; i < (int)(g[v].size()); i++) {
    int to = g[v][i].first;
    if (to != p) {
      dp1[to] = dp1[v] + g[v][i].second;
      dp2[to] = dp2[v] + 1 - g[v][i].second;
      cnt += g[v][i].second;
      int rr = dfs(to, v);
      if (rr < mi1) {
        mi2 = mi1;
        mi1 = rr;
      } else if (rr < mi2)
        mi2 = rr;
    }
  }
  int ret = mi1;
  if (p == -1) ret += mi2;
  return ret;
}
int main() {
  int(n);
  input((n));
  ;
  if (n == 1) {
    puts("0");
    return 0;
  }
  g.resize(n);
  dp1.resize(n);
  dp2.resize(n);
  for (int i = 0; i < (int)(n - 1); i++) {
    int(a);
    input((a));
    ;
    int(b);
    input((b));
    ;
    g[a - 1].push_back(make_pair(b - 1, 0));
    g[b - 1].push_back(make_pair(a - 1, 1));
  }
  dfs(0, -1);
  int val[n];
  int ans = 1e9;
  for (int i = 0; i < (int)(n); i++) {
    val[i] = cnt - dp1[i] + dp2[i];
    ans = min(ans, val[i]);
  }
  for (int i = 0; i < (int)(n); i++) {
    dp1.assign(n, 0);
    dp2.assign(n, 0);
    ans = min(val[i] + dfs(i, -1), ans);
  }
  cout << ans << endl;
  return 0;
}
