#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const int MAXN = 20010;
const int INF = 0x3f3f3f3f;
const double eps = 0.0000001;
const long long mod = 1e9 + 7;
long long n, m, x, y, z, k, cnt, t, len, q;
struct note {
  long long u, v, w;
} h;
vector<note> E[N];
long long dp[N], val[N];
long long ans = INF, sum = 0, sum_f = 0;
void dfs(int u, int fa) {
  sum_f = max(sum_f, dp[u]);
  for (int i = 0; i < E[u].size(); i++) {
    int v = E[u][i].v;
    if (v == fa) continue;
    sum += (E[u][i].w == -1);
    dp[v] = max(0ll, dp[u] - E[u][i].w);
    dfs(v, u);
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i < n; i++) {
    long long u, v, w;
    scanf("%lld%lld", &u, &v);
    h.u = u, h.v = v, h.w = 1;
    E[u].push_back(h);
    h.u = v, h.v = u, h.w = -1;
    E[v].push_back(h);
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = 0;
    sum = sum_f = 0;
    dfs(i, -1);
    ans = min(ans, sum - sum_f);
  }
  printf("%lld", ans);
}
