#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MAX = 1e9 + 5;
int i, j, temp, k, n, m, x, y, ans[N], res = 1000000000;
vector<pair<int, int> > v[N];
void calc(int node, int root) {
  for (__typeof(v[node].begin()) it = v[node].begin(); it != v[node].end();
       it++) {
    if (it->first == root) continue;
    ans[1] += it->second;
    calc(it->first, node);
  }
}
void dfs(int node, int root) {
  for (__typeof(v[node].begin()) it = v[node].begin(); it != v[node].end();
       it++) {
    if (it->first == root) continue;
    ans[it->first] = ans[node] - 2 * (it->second) + 1;
    dfs(it->first, node);
  }
}
void solve(int node, int root, int bef) {
  temp = max(temp, bef);
  for (__typeof(v[node].begin()) it = v[node].begin(); it != v[node].end();
       it++) {
    if (it->first == root) continue;
    solve(it->first, node, max(0, bef + 2 * (it->second) - 1));
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d %d", &x, &y);
    v[x].push_back(make_pair(y, 0));
    v[y].push_back(make_pair(x, 1));
  }
  calc(1, 0);
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    temp = 0;
    solve(i, 0, 0);
    res = min(res, ans[i] - temp);
  }
  cout << res << '\n';
  return 0;
}
