#include <bits/stdc++.h>
using namespace std;
inline void wait(double seconds) {
  double endtime = clock() + (seconds * CLOCKS_PER_SEC);
  while (clock() < endtime) {
    ;
  }
}
template <class T>
inline T fastIn() {
  register char c = 0;
  register T a = 0;
  bool neg = false;
  while (c < 33) c = getchar();
  while (c > 33) {
    if (c == '-') {
      neg = true;
    } else {
      a = (a * 10) + (c - '0');
    }
    c = getchar();
  }
  return neg ? -a : a;
}
const int MX = (int)3e4 + 5;
struct node {
  int to, cc;
};
vector<node> adj[MX];
int node_count;
inline void read() {
  for (auto &x : adj) x.clear();
  node_count = fastIn<int>();
  for (int i = 0, j1 = node_count - 1; i < j1; ++i) {
    int u = fastIn<int>() - 1, v = fastIn<int>() - 1;
    adj[u].push_back(node{v, 0});
    adj[v].push_back(node{u, 1});
  }
}
int total_cost1, total_cost2;
bool seen[MX];
void dfs(int u, int c) {
  seen[u] = true;
  total_cost2 = max(total_cost2, c);
  for (auto &x : adj[u]) {
    int to = x.to, cc = x.cc;
    if (seen[to] == false) {
      total_cost1 += cc;
      int nxtc = max(0, c + 2 * cc - 1);
      dfs(to, nxtc);
    }
  }
}
inline void proc() {
  int bst = (int)1023456789;
  if (node_count <= 2) {
    cout << 0 << "\n";
    return;
  }
  for (int u = 0, j1 = node_count; u < j1; ++u) {
    memset(seen, false, sizeof(seen));
    total_cost1 = total_cost2 = 0;
    dfs(u, 0);
    bst = min(bst, total_cost1 - total_cost2);
  }
  cout << bst << '\n';
}
int main() {
  int kase = 1;
  for (int i = 0, j1 = kase; i < j1; ++i) {
    read();
    proc();
  }
  return 0;
}
