#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int(i) = 0; (i) < (((int)((t).size()))); ++(i)) s << t[i] << " ";
  return s;
}
vector<pair<int, int> > adj[100007];
int czyms[100007], rootem[100007];
void go(int v, int p) {
  int sumarootemijedynek = 0;
  for (typeof(adj[v].begin()) x = adj[v].begin(); x != adj[v].end(); x++)
    if (x->first != p) {
      go(x->first, v);
      sumarootemijedynek += rootem[x->first] + x->second;
    }
  rootem[v] = sumarootemijedynek;
  czyms[v] = rootem[v];
  for (typeof(adj[v].begin()) x = adj[v].begin(); x != adj[v].end(); x++)
    if (x->first != p) {
      (czyms[v]) =
          min((czyms[v]), (sumarootemijedynek - (rootem[x->first] + x->second) +
                           czyms[x->first] + 1 - x->second));
      ;
    }
}
int control(int v, int p) {
  go(v, p);
  return czyms[v];
}
int main() {
  int(n);
  scanf("%d", &(n));
  vector<pair<int, int> > v;
  for (int(k) = 0; (k) < (n - 1); ++(k)) {
    int(ai), (bi);
    scanf("%d %d", &(ai), &(bi));
    v.push_back(make_pair(ai, bi));
    adj[ai].push_back(make_pair(bi, 0));
    adj[bi].push_back(make_pair(ai, 1));
  }
  int best = control(1, -1);
  for (int(k) = 0; (k) < (n - 1); ++(k)) {
    int ai = v[k].first, bi = v[k].second;
    (best) = min((best), (control(ai, bi) + control(bi, ai)));
    ;
  }
  pisz(best);
}
